Server Error in '/test' Application.

  • Thread starter Thread starter Moe Sizlak
  • Start date Start date
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.
 
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...
 
Back
Top