D
darrel
I'm tring to modify an existing DB connection/query into a parameterized
one. But, in doing so, I get an error stating that I am not defining the
variable I am using in the query.
This is what I have:
=================================================================
Dim DS As New DataSet
Dim strConnect As String
strConnect =
System.Configuration.ConfigurationSettings.AppSettings("DBConn")
Dim strChk As String
strChk = "SELECT CAT.categoryID, CAT.categoryParentID, CAT.categoryName,
PARENTCAT.categoryName AS parentCategoryName FROM categories CAT LEFT OUTER
JOIN categories PARENTCAT ON CAT.categoryParentID = PARENTCAT.categoryID
WHERE(CAT.categoryID = @categoryID)"
Dim objConnect As New System.Data.OleDb.OleDbConnection(strConnect)
objConnect.Open()
Dim objCommand As New System.Data.OleDb.OleDbCommand(strChk, objConnect)
objCommand.Parameters.Add("@categoryID", categoryID)
Dim objOleDbAdapter As New System.Data.OleDb.OleDbDataAdapter(strChk,
strConnect)
objOleDbAdapter.Fill(DS, "webPages")
=================================================================
I'm guessing it has to do with my Connection not passing the command to the
DB?
-Darrel
one. But, in doing so, I get an error stating that I am not defining the
variable I am using in the query.
This is what I have:
=================================================================
Dim DS As New DataSet
Dim strConnect As String
strConnect =
System.Configuration.ConfigurationSettings.AppSettings("DBConn")
Dim strChk As String
strChk = "SELECT CAT.categoryID, CAT.categoryParentID, CAT.categoryName,
PARENTCAT.categoryName AS parentCategoryName FROM categories CAT LEFT OUTER
JOIN categories PARENTCAT ON CAT.categoryParentID = PARENTCAT.categoryID
WHERE(CAT.categoryID = @categoryID)"
Dim objConnect As New System.Data.OleDb.OleDbConnection(strConnect)
objConnect.Open()
Dim objCommand As New System.Data.OleDb.OleDbCommand(strChk, objConnect)
objCommand.Parameters.Add("@categoryID", categoryID)
Dim objOleDbAdapter As New System.Data.OleDb.OleDbDataAdapter(strChk,
strConnect)
objOleDbAdapter.Fill(DS, "webPages")
=================================================================
I'm guessing it has to do with my Connection not passing the command to the
DB?
-Darrel