param datagrid question

  • Thread starter Patrick Olurotimi Ige
  • Start date
P

Patrick Olurotimi Ige

Why does this Sub program work well with ASP.NET Web MAtrix and gives
ERROR when compiled in VS.NET 2003 :-
"Prepared statement '(@State nvarchar(2))select * from Authors where
state = @State' expects parameter @State, which was not supplied."

The error comes at line :-
MyCommand.SelectCommand.Parameters("@State").Value = MySelect.Value


Sub GetAuthors_Click(Sender As Object, E As EventArgs)

Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter

Dim SelectCommand As String = "select * from Authors where state
= @State"

MyConnection = New
SqlConnection("server=(local);database=pubs;integrated security=true;")
MyCommand = New SqlDataAdapter(SelectCommand, MyConnection)

MyCommand.SelectCommand.Parameters.Add(New
SqlParameter("@State", SqlDbType.NVarChar, 2))
MyCommand.SelectCommand.Parameters("@State").Value =
MySelect.Value

DS = new DataSet()
MyCommand.Fill(DS, "Authors")

MyDataGrid.DataSource=DS.Tables("Authors").DefaultView
MyDataGrid.DataBind()
End Sub
 

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

Similar Threads

Param dataGrid Question 2
need some help 1
need help - -PLEASE 3
asp.net problem 2
Newbie Question 5
Refreshing DataGrid in page_load 7
Simple Datagrid sort problem 0
CheckBoxList in DataList Question? 4

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,949
Members
47,500
Latest member
ArianneJsb

Latest Threads

Top