Adding parameters to stored procedures

  • Thread starter Thread starter Bonzol
  • Start date Start date
B

Bonzol

Thanx to the help of other memebers on this group i've gotten to where
I am

however, I seem unable to add the required paramater to my stored
procedure

my code

Dim toreturn As System.Data.DataTable
' Try
Me.SqlConnection1.Open()
Me.SqlSelectCommand1.CommandText = "[CustOrdersOrders]"
Me.SqlSelectCommand1.Parameters.AddWithValue("@CustomerID",
"VINET")
Me.SqlSelectCommand1.ExecuteNonQuery()
Me.SqlDataAdapter1 = New
System.Data.SqlClient.SqlDataAdapter(Me.SqlSelectCommand1.CommandText,
Me.SqlConnection1)
Dim dt As System.Data.DataTable
dt = New System.Data.DataTable
Me.SqlDataAdapter1.Fill(dt)

Me.SqlConnection1.Close()
toreturn = dt
'Catch

'End Try
Return toreturn


the error

Procedure 'CustOrdersOrders' expects parameter '@CustomerID', which was
not supplied


any help?

thanx in advance
 
Bonzol,

You try modifying your code like this:

Dim toreturn As System.Data.DataTable
' Try
Me.SqlConnection1.Open()
Me.SqlSelectCommand1.CommandText = "[CustOrdersOrders]"
Me.SqlSelectCommand1.Parameters.AddWithValue("@CustomerID", "VINET")
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlDataAdapter1 = New
System.Data.SqlClient.SqlDataAdapter(Me.SqlSelectCommand1)
Dim dt As System.Data.DataTable
dt = New System.Data.DataTable
Me.SqlDataAdapter1.Fill(dt)

Me.SqlConnection1.Close()
toreturn = dt
'Catch

'End Try
Return toreturn

Kerry Moorman
 
Cheers
Kerry said:
Bonzol,

You try modifying your code like this:

Dim toreturn As System.Data.DataTable
' Try
Me.SqlConnection1.Open()
Me.SqlSelectCommand1.CommandText = "[CustOrdersOrders]"
Me.SqlSelectCommand1.Parameters.AddWithValue("@CustomerID", "VINET")
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlDataAdapter1 = New
System.Data.SqlClient.SqlDataAdapter(Me.SqlSelectCommand1)
Dim dt As System.Data.DataTable
dt = New System.Data.DataTable
Me.SqlDataAdapter1.Fill(dt)

Me.SqlConnection1.Close()
toreturn = dt
'Catch

'End Try
Return toreturn

Kerry Moorman


Bonzol said:
Thanx to the help of other memebers on this group i've gotten to where
I am

however, I seem unable to add the required paramater to my stored
procedure

my code

Dim toreturn As System.Data.DataTable
' Try
Me.SqlConnection1.Open()
Me.SqlSelectCommand1.CommandText = "[CustOrdersOrders]"
Me.SqlSelectCommand1.Parameters.AddWithValue("@CustomerID",
"VINET")
Me.SqlSelectCommand1.ExecuteNonQuery()
Me.SqlDataAdapter1 = New
System.Data.SqlClient.SqlDataAdapter(Me.SqlSelectCommand1.CommandText,
Me.SqlConnection1)
Dim dt As System.Data.DataTable
dt = New System.Data.DataTable
Me.SqlDataAdapter1.Fill(dt)

Me.SqlConnection1.Close()
toreturn = dt
'Catch

'End Try
Return toreturn


the error

Procedure 'CustOrdersOrders' expects parameter '@CustomerID', which was
not supplied


any help?

thanx in advance
 
Bonzol,

Be aware that the sample as Kerry gave you is only working after evertime
initializing the command.
If you using the parameter more than you have only to set the value of the
command

Me.SqlSelectCommand1.Parameters("@CustomerId").Value = "BINET"

Just as addition

Cor


Bonzol said:
Cheers
Kerry said:
Bonzol,

You try modifying your code like this:

Dim toreturn As System.Data.DataTable
' Try
Me.SqlConnection1.Open()
Me.SqlSelectCommand1.CommandText = "[CustOrdersOrders]"
Me.SqlSelectCommand1.Parameters.AddWithValue("@CustomerID",
"VINET")
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlDataAdapter1 = New
System.Data.SqlClient.SqlDataAdapter(Me.SqlSelectCommand1)
Dim dt As System.Data.DataTable
dt = New System.Data.DataTable
Me.SqlDataAdapter1.Fill(dt)

Me.SqlConnection1.Close()
toreturn = dt
'Catch

'End Try
Return toreturn

Kerry Moorman


Bonzol said:
Thanx to the help of other memebers on this group i've gotten to where
I am

however, I seem unable to add the required paramater to my stored
procedure

my code

Dim toreturn As System.Data.DataTable
' Try
Me.SqlConnection1.Open()
Me.SqlSelectCommand1.CommandText = "[CustOrdersOrders]"
Me.SqlSelectCommand1.Parameters.AddWithValue("@CustomerID",
"VINET")
Me.SqlSelectCommand1.ExecuteNonQuery()
Me.SqlDataAdapter1 = New
System.Data.SqlClient.SqlDataAdapter(Me.SqlSelectCommand1.CommandText,
Me.SqlConnection1)
Dim dt As System.Data.DataTable
dt = New System.Data.DataTable
Me.SqlDataAdapter1.Fill(dt)

Me.SqlConnection1.Close()
toreturn = dt
'Catch

'End Try
Return toreturn


the error

Procedure 'CustOrdersOrders' expects parameter '@CustomerID', which was
not supplied


any help?

thanx in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top