J
James Cooke
Hi all, please help me!
New to OLEDB in ASP.net, converting from SQL to OLEDB.
Below is a code snippet that executes under a connection that is known to be OK, since I can read the database using it OK.
I have highlighted the code for easier reading. Thanks in advance for any help!
--------------------------------------------------------------------------------
Private m_OLEDBConnection As System.Data.OleDb.OleDbConnection
Private m_ConnectionString As String
m_ConnectionString = System.Configuration.ConfigurationSettings.AppSettings("OLEDBConnectionString")
m_OLEDBConnection = New System.Data.OleDb.OleDbConnection(m_ConnectionString)
m_OLEDBConnection.Open()
This connection code works because it retrieves data OK
--------------------------------------------------------------------------------
Using the connection
Dim OLEDBCommandObject As System.Data.OleDb.OleDbCommand
Dim OLEDBParam As System.Data.OleDb.OleDbParameter
DIM SQL As String
SQL = "UPDATE Tree SET Site=@Site WHERE Tree=5612"
OLEDBCommandObject = New System.Data.OleDb.OleDbCommand(SQL, m_OLEDBConnection)
OLEDBParam = OLEDBCommandObject.Parameters.Add(New System.Data.oledb.OleDbParameter("@Site", System.Data.OleDb.OleDbType.Integer, 4))
OLEDBParam.Value = 1
OLEDBParam.SourceColumn = "Site"
Try
m_ReturnValue = OLEDBCommandObject.ExecuteScalar
Catch e As System.Data.SqlClient.SqlException
throw
End Try
The error comes up as follows
--------------------------------------------------------------------------------
Server Error in '/CPublisher' Application.
Must declare the variable '@Site'.
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.OleDb.OleDbException: Must declare the variable '@Site'.
New to OLEDB in ASP.net, converting from SQL to OLEDB.
Below is a code snippet that executes under a connection that is known to be OK, since I can read the database using it OK.
I have highlighted the code for easier reading. Thanks in advance for any help!
--------------------------------------------------------------------------------
Private m_OLEDBConnection As System.Data.OleDb.OleDbConnection
Private m_ConnectionString As String
m_ConnectionString = System.Configuration.ConfigurationSettings.AppSettings("OLEDBConnectionString")
m_OLEDBConnection = New System.Data.OleDb.OleDbConnection(m_ConnectionString)
m_OLEDBConnection.Open()
This connection code works because it retrieves data OK
--------------------------------------------------------------------------------
Using the connection
Dim OLEDBCommandObject As System.Data.OleDb.OleDbCommand
Dim OLEDBParam As System.Data.OleDb.OleDbParameter
DIM SQL As String
SQL = "UPDATE Tree SET Site=@Site WHERE Tree=5612"
OLEDBCommandObject = New System.Data.OleDb.OleDbCommand(SQL, m_OLEDBConnection)
OLEDBParam = OLEDBCommandObject.Parameters.Add(New System.Data.oledb.OleDbParameter("@Site", System.Data.OleDb.OleDbType.Integer, 4))
OLEDBParam.Value = 1
OLEDBParam.SourceColumn = "Site"
Try
m_ReturnValue = OLEDBCommandObject.ExecuteScalar
Catch e As System.Data.SqlClient.SqlException
throw
End Try
The error comes up as follows
--------------------------------------------------------------------------------
Server Error in '/CPublisher' Application.
Must declare the variable '@Site'.
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.OleDb.OleDbException: Must declare the variable '@Site'.