D
darrel
I've been struggling with getting paramaterized SQL to work for a few days.
I got a bit of help last week and seemed to heading in the right direction,
bu I keep getting a 'must declare @cateogoryID variable' error when trying
to execute the following. Does anyone see something obviously wrong with my
syntax?
===============================
Dim strConnect As String
strConnect =
System.Configuration.ConfigurationSettings.AppSettings("DBConn")
Dim objConnect As New System.Data.OleDb.OleDbConnection(strConnect)
objConnect.Open()
Dim strChk As String
strChk = "SELECT CAT.categoryID, CAT.categoryParentID, CAT.categoryName,
PARENTCAT.categoryName AS parentCategoryName FROM We_about_categories CAT
LEFT OUTER JOIN We_about_categories PARENTCAT ON CAT.categoryParentID =
PARENTCAT.categoryID WHERE(CAT.categoryID = @categoryID)"
Dim objCommand As New System.Data.OleDb.OleDbCommand(strChk, objConnect)
Dim objOleDbAdapter As New System.Data.OleDb.OleDbDataAdapter(strChk,
strConnect)
objCommand.Parameters.Add("@categoryID",
System.Data.OleDb.OleDbType.Numeric).Value = categoryID
objOleDbAdapter.SelectCommand = objCommand
objOleDbAdapter.Fill(DS, "webPages")
===============================
I got a bit of help last week and seemed to heading in the right direction,
bu I keep getting a 'must declare @cateogoryID variable' error when trying
to execute the following. Does anyone see something obviously wrong with my
syntax?
===============================
Dim strConnect As String
strConnect =
System.Configuration.ConfigurationSettings.AppSettings("DBConn")
Dim objConnect As New System.Data.OleDb.OleDbConnection(strConnect)
objConnect.Open()
Dim strChk As String
strChk = "SELECT CAT.categoryID, CAT.categoryParentID, CAT.categoryName,
PARENTCAT.categoryName AS parentCategoryName FROM We_about_categories CAT
LEFT OUTER JOIN We_about_categories PARENTCAT ON CAT.categoryParentID =
PARENTCAT.categoryID WHERE(CAT.categoryID = @categoryID)"
Dim objCommand As New System.Data.OleDb.OleDbCommand(strChk, objConnect)
Dim objOleDbAdapter As New System.Data.OleDb.OleDbDataAdapter(strChk,
strConnect)
objCommand.Parameters.Add("@categoryID",
System.Data.OleDb.OleDbType.Numeric).Value = categoryID
objOleDbAdapter.SelectCommand = objCommand
objOleDbAdapter.Fill(DS, "webPages")
===============================