EziData Solutions

Web, NET and SQL Server

Adding Parameters to Access Queries

Option 1:

Create a Parameter object and add this to an existing Command object.

'Create a new parameter

Dim myParam As New OleDbParameter("ParamName", paramValue)

'add the parameter to the command

cmd.Parameters.Add(myParam)

Option 2:

Use the AddWithValue option to add a Parameter directly to the Command object.

'create, assign value and add a new parameter to the command

cmd.Parameters.AddWithValue("ParamName", paramValue)

 

Posted: Oct 06 2009, 21:31 by Admin | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Access

Adding Parameters to SQL Server Queries

Option 1:

Create a new Parameter object for each parameter required in the SQL query or Stored Procedure.

//Create a new command object

SqlCommand cmd = new SqlCommand();

 

//Create a new parameter

SqlParameter param = new SqlParameter("@parameterName", paramValue);

 

//add the parameter to the command

cmd.Parameters.Add(param);

Option 2:

Use the AddWithValue, to create Parameter and assign a value to a Command object.

//Create a new command object

SqlCommand cmd = new SqlCommand();

 

//add the parameter to the command

cmd.Parameters.AddWithValue("@parameterName", paramValue);

Posted: Oct 06 2009, 21:23 by CameronM | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: SQL Server | SQL Server