Server Error in '/test' Application.

M

Moe Sizlak

Hi,

I am using an SQL parameter in my SQL statement, I have never done this
before ans it seems to be retuning an error saying that the parameter '@ID'
must be declared, I know I am close, could someone have a look at it form me
please?

cheers lads

Moe

Dim DS As New DataSet()
Dim sqlCMD as new sqlCommand
sqlCMD.parameters.add(New SqlParameter("@ID", SqlDbType.Int, 4))
sqlCMD.parameters("@ID").value = PersonID
Dim strConnect As New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
Dim objSQLAdapter As New SQLDataAdapter("SELECT FROM table WHERE person=
@ID", strConnect)



objSQLAdapter.Fill(DS, "table")


Server Error in '/test' Application.
 
M

Miha Markic [MVP C#]

Hi Moe,

Either use sqlCMD as DataAdapter.SelectCommand (and adjust its CommandText)
or add a parameter to objSQLAdapter.SelectCommand.
Your sqlCMD is currently used nowhere...
 

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

Top