Re: Getting Desparate!!! - Must declare the variable '@CategoryName'.
From: xs (blizzardstorm8899_at_yahoo.com.sg)
Date: 03/29/04
- Next message: xs: "Re: Getting Desparate!!! - Must declare the variable '@CategoryName'."
- Previous message: Boris Dynin: "Re: Stored procedure with 'insert' or 'update' doesn't return rowset."
- In reply to: James Cooke: "Re: Getting Desparate!!! - Must declare the variable '@CategoryName'."
- Next in thread: xs: "Re: Getting Desparate!!! - Must declare the variable '@CategoryName'."
- Reply: xs: "Re: Getting Desparate!!! - Must declare the variable '@CategoryName'."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 29 Mar 2004 16:08:23 +0800
U can try
Dim SQL As String = "UPDATE categories SET CategoryName=? WHERE CategoryID
=1"
and then
OLEDBParam = New System.Data.oledb.OleDbParameter("CategoryName",
System.Data.OleDb.OleDbType.VarChar, 15)
"James Cooke" <jamescooke_txS_P_A_M_L_E_S_S@yahoo.com> wrote in message
news:%23uPUod7EEHA.2804@tk2msftngp13.phx.gbl...
> Thanks, I tried this. Having changed both '@' to '?' to the following, as
in the lines below, I get a similar error:
>
> Exception Details: System.Data.OleDb.OleDbException: Must declare the
variable '@P1CategoryName'.
>
> Dim ConnectionString As String = "etc etc"
> Dim OLEDBConnection As New
System.Data.OleDb.OleDbConnection(ConnectionString)
> Dim SQL As String = "UPDATE categories SET
CategoryName=?CategoryName WHERE CategoryID =1"
> Dim OLEDBCommandObject As New System.Data.OleDb.OleDbCommand(SQL,
OLEDBConnection)
> Dim OLEDBParam As System.Data.OleDb.OleDbParameter
>
> OLEDBParam = New System.Data.oledb.OleDbParameter("?CategoryName",
System.Data.OleDb.OleDbType.VarChar, 15)
> OLEDBParam.Value = 1
> OLEDBParam.SourceColumn = "CategoryName"
> OLEDBCommandObject.Parameters.Add(OLEDBParam)
>
> OLEDBConnection.Open()
> OLEDBCommandObject.ExecuteNonQuery()
> OLEDBConnection.Close()
>
>
> Thanks in advance
>
> James
>
>
> "xs" <blizzardstorm8899@yahoo.com.sg> wrote in message
news:%2332U7D7EEHA.1452@TK2MSFTNGP09.phx.gbl...
> For OLE parameters should start with ? instead of @. @ is for SqlClient
>
> "James Cooke" <jamescooke_txS_P_A_M_L_E_S_S@yahoo.com> wrote in message
> news:O5m2t66EEHA.2976@TK2MSFTNGP12.phx.gbl...
> > Trying to update nortwhind table, no matter what I do, I
> > always get this error:
> >
> > Server Error in '/WebApplication1' Application.
> > Must declare the variable '@CategoryName'.
> >
> > The connection is definitely working, the user has
> > read/write authority and I can read the database. Updating
> > it with parameters fails. This is the code:
> >
> > Public Class WebForm1
> > Private Sub Page_Load(ByVal sender As System.Object,
> > ByVal e As System.EventArgs) Handles MyBase.Load
> > Dim OLEDBConnection As
> > System.Data.OleDb.OleDbConnection
> > Dim ConnectionString As String
> > ConnectionString = "Provider=SQLOLEDB.1;Persist
> > Security Info=True;Password=crow;User ID=cladion;Initial
> > Catalog=Northwind;Data Source=IS-JCOOKE0"
> > OLEDBConnection = New
> > System.Data.OleDb.OleDbConnection(ConnectionString)
> > OLEDBConnection.Open()
> > Dim OLEDBCommandObject As
> > System.Data.OleDb.OleDbCommand
> > Dim OLEDBParam As System.Data.OleDb.OleDbParameter
> > Dim SQL As String
> >
> >
> > SQL = "UPDATE categories SET
> > CategoryName=@CategoryName WHERE CategoryID =1"
> > OLEDBCommandObject = New
> > System.Data.OleDb.OleDbCommand(SQL, OLEDBConnection)
> >
> > OLEDBParam = OLEDBCommandObject.Parameters.Add(New
> > System.Data.oledb.OleDbParameter("@CategoryName",
> > System.Data.OleDb.OleDbType.VarChar, 15))
> > OLEDBParam.Value = 1
> > OLEDBParam.SourceColumn = "CategoryName"
> > OLEDBCommandObject.ExecuteNonQuery()
> > OLEDBConnection.Close()
> > End Sub
> >
> > End Class
> >
> >
>
>
>
- Next message: xs: "Re: Getting Desparate!!! - Must declare the variable '@CategoryName'."
- Previous message: Boris Dynin: "Re: Stored procedure with 'insert' or 'update' doesn't return rowset."
- In reply to: James Cooke: "Re: Getting Desparate!!! - Must declare the variable '@CategoryName'."
- Next in thread: xs: "Re: Getting Desparate!!! - Must declare the variable '@CategoryName'."
- Reply: xs: "Re: Getting Desparate!!! - Must declare the variable '@CategoryName'."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|