Re: oledb date/time insert command format

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
>
>




.



Relevant Pages

  • Re: Using Net Use command...
    ... A syntax error means there's something wrong with the command itself, not the result of the command. ... You can only map a drive to a share, not a folder. ... So I'm on my network, but is there another way to just browse to a directory? ...
    (microsoft.public.windows.server.networking)
  • Re: ORDER in the 49G+ compared to the 48G; Question about executing keys
    ... > aplnub wrote: ... > "Syntax Error" only happens when you validate a command line and the ... > syntax in the command is ... ... I want to exectue the NXT function from a program. ...
    (comp.sys.hp48)
  • Re: Regular Expression Problem
    ... It's not a problem with the command line, or anything like that, it's ... hopesprings# cat> test.pl ... syntax error at ./test.pl line 12, near ""Test two contains toast and ...
    (perl.beginners)
  • Re: Regular Expression Problem
    ... It's not a problem with the command line, or anything like that, it's ... hopesprings# cat> test.pl ... syntax error at ./test.pl line 12, near ""Test two contains toast and ...
    (perl.beginners)
  • Re: Regular Expression Problem
    ... It's not a problem with the command line, or anything like that, it's ... hopesprings# cat> test.pl ... syntax error at ./test.pl line 12, near ""Test two contains toast and ...
    (perl.beginners)