I'm having problems trying to fill in the DataSet using SQL Server 2005. Basically I have a table in SQL Server and I want to retrieve those information and be able to display it in a web browser using DataSet. Whenever I run my code I always get error message:
Line 1: Incorrect syntax near '?'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '?'.
Source Error:
Line 16: ProductDA = New SqlDataAdapter("Select * From Surfzone Where SBID = ?", objConn)
Line 17:
Line 18: ProductDA.Fill(ProductDS)
Line 19:
Line 20: Return ProductDS.Tables(0)
-------------------------------------------------------------------------------
Here's my code:
Imports System.Data
Imports System.Data.SqlClient
Namespace SurfZone
Public Class Products
Public Function RetrieveProductData(ByVal IDProduct As Integer) As DataTable
Dim objConn As SqlConnection
Dim ProductDA As SqlDataAdapter
Dim ProductDS As New DataSet
objConn = New SqlConnection("Data Source=0.0.0.0;Initial Catalog=DBNAME;Persist Security Info=TRUE;User ID=USERID;Password=PASSWORD")
ProductDA = New SqlDataAdapter("Select * From TABLENAME Where ID = ?", objConn)
ProductDA.Fill(ProductDS)
Return ProductDS.Tables(0)
End Function
End Class
End Namespace
---------------------------------------------------------------------------
Any ideas??
Thanks!