Re: oledb date/time insert command format
- From: "SvenC" <SvenC@xxxxxxxxxxxxxxxx>
- Date: Mon, 16 Oct 2006 13:38:39 +0200
Hi mabond,
"mabond" <mabond@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:53F9FB8E-F63B-414A-AF83-CC7C65F4B72E@xxxxxxxxxxxxxxxx
SvenC
thanks for quicke response, however your suggestion has not resolved the
issue. I'm still receiving a syntax error in "insert into" command
I never used Access and Oledb, so I am just guessing. Here is the next guess:
I seem to remember that parameters might be declared with a ? in the command string, so you could try to replace @fone, @ftwo, @fthree with ?, ?, ?
The questionmarks are bound to parameters by position because they do not have unique names anymore.
You might also have to explicitly state the length of strings you pass. Though that would rather show up as a problem of data lost on the way to the DB table and not as runtime error.
--
SvenC
Regards
Michael
"SvenC" wrote:
Hi mabond
"mabond" <mabond@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9A6E8254-2893-4A08-BA69-0B2A51E32748@xxxxxxxxxxxxxxxx
> Hi
>
> VB.NET 2005 Express edition
> Microsoft Access 2000 (SP-3)
>
> Having trouble writing an "insert into" command for a Microsoft table > I'm
> accessing through oledb.
>
> I've tried to follow the same principle I'd use if it was an sql > database
> but I'm getting an error telling me the syntax of the "insert into"
> command
> is incorrect.
<snip/>
> insertCMD = "INSERT INTO myTable (field1, field2, field3) VALUES
> (@fone, @ftwo, @fthree);"
Try this INSERT command without the trailing ;
--
SvenC
> myCommand = New OleDbCommand(insertCMD, myConnection)
> myCommand.Parameters.Add(New OleDbParameter("@fone",
> OleDbType.Integer))
> myCommand.Parameters.Add(New OleDbParameter("@ftwo",
> OleDbType.VarChar))
> myCommand.Parameters.Add(New OleDbParameter("@fthree",
> OleDbType.Date)) '? not sure if this is the correct object type
> myCommand.Parameters(0).Value = Me.fonelabel.Text
> myCommand.Parameters(1).Value = Me.ftwolabel.Text
> myCommand.Parameters(2).Value = Now() 'must insert both date and
> time, not just date
>
> myConnection.Open()
> myCommand.ExecuteNonQuery()
> myConnection.Close()
>
> End Sub
>
> End class
>
>
> Any help appreciated
>
> Thanks
>
> Michael Bond
>
>
.
- Follow-Ups:
- Re: oledb date/time insert command format
- From: mabond
- Re: oledb date/time insert command format
- References:
- oledb date/time insert command format
- From: mabond
- Re: oledb date/time insert command format
- From: SvenC
- Re: oledb date/time insert command format
- From: mabond
- oledb date/time insert command format
- Prev by Date: Re: oledb date/time insert command format
- Next by Date: Where's my dll after I build?
- Previous by thread: Re: oledb date/time insert command format
- Next by thread: Re: oledb date/time insert command format
- Index(es):
Relevant Pages
|