S
sean
Hi
I am trying to execute an ms access stored query, I keep getting an error
when I try to execute the code.I know that I am missing some declarations in
my script, I am just not sure on the syntax.
Sean
error -----------------------------------
Line 49: Try
Line 50: objConn.Open()
Line 51: DG1.DataSource = objCmd.ExecuteReader
Line 52: DG1.DataBind()
Line 53:
!--------------------------------- code
Dim strConnect As String
Dim DG1 as SqlDataReader
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConnect += "Data Source =" & Server.MapPath("1t.mdb") & ";"
strConnect += "Persist Security Info=False"
Dim objConn As New OleDbConnection(strConnect)
Dim objCmd As New OleDbCommand()
Dim objParam As OleDbParameter
With objCmd
.Connection = objConn
.CommandText = "sp_deletebyid"
.CommandType = CommandType.StoredProcedure
objParam = .Parameters.Add("ID", OleDbType.Integer)
End With
objParam.Direction = ParameterDirection.Input
objParam.Value = strChkBoxValue
Try
objConn.Open()
DG1.DataSource = objCmd.ExecuteReader
DG1.DataBind()
Catch objError As Exception
lblMessage.Text = objError.Message
Finally
objConn.Close()
End Try
I am trying to execute an ms access stored query, I keep getting an error
when I try to execute the code.I know that I am missing some declarations in
my script, I am just not sure on the syntax.
Sean
error -----------------------------------
Line 49: Try
Line 50: objConn.Open()
Line 51: DG1.DataSource = objCmd.ExecuteReader
Line 52: DG1.DataBind()
Line 53:
!--------------------------------- code
Dim strConnect As String
Dim DG1 as SqlDataReader
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConnect += "Data Source =" & Server.MapPath("1t.mdb") & ";"
strConnect += "Persist Security Info=False"
Dim objConn As New OleDbConnection(strConnect)
Dim objCmd As New OleDbCommand()
Dim objParam As OleDbParameter
With objCmd
.Connection = objConn
.CommandText = "sp_deletebyid"
.CommandType = CommandType.StoredProcedure
objParam = .Parameters.Add("ID", OleDbType.Integer)
End With
objParam.Direction = ParameterDirection.Input
objParam.Value = strChkBoxValue
Try
objConn.Open()
DG1.DataSource = objCmd.ExecuteReader
DG1.DataBind()
Catch objError As Exception
lblMessage.Text = objError.Message
Finally
objConn.Close()
End Try