Home All Groups Group Topic Archive Search About
Author
30 Jun 2006 9:00 AM
reidarT
I got help from Cor L, but is not finished yet.

In a windows form I need to add a date to a table in Access.

Dim dteDato As Date = (Me.txtDato.Text)     ' I have tried Value instead of
Text, but it doesn't help
Dim con As New OleDb.OleDbConnection("Provider=Micr.....
Dim cmd As New OleDb.OleDbCommand("INSERT INTO tblToDo ( Dato ) SELECT " &
dteDato, con)
....
The dteDato shows as #6/30/2006#
The table in access has the field as Date, Short date.
The message I get is Syntax error in number in query expression 30.06.2006
(norwegian format)
I can't find ut what's wrong.
reidarT

Author
30 Jun 2006 12:23 PM
Cor Ligthert [MVP]
Reidar,

I saw you changed your dateandtime already on your computer,

However can you declare further, is this an insert commando from a
dataadapter or just an insert commando for an executenonquery

Cor

Show quoteHide quote
"reidarT" <rei***@eivon.no> schreef in bericht
news:uOAGiNCnGHA.4348@TK2MSFTNGP02.phx.gbl...
>I got help from Cor L, but is not finished yet.
>
> In a windows form I need to add a date to a table in Access.
>
> Dim dteDato As Date = (Me.txtDato.Text)     ' I have tried Value instead
> of Text, but it doesn't help
> Dim con As New OleDb.OleDbConnection("Provider=Micr.....
> Dim cmd As New OleDb.OleDbCommand("INSERT INTO tblToDo ( Dato ) SELECT " &
> dteDato, con)
> ...
> The dteDato shows as #6/30/2006#
> The table in access has the field as Date, Short date.
> The message I get is Syntax error in number in query expression 30.06.2006
> (norwegian format)
> I can't find ut what's wrong.
> reidarT
>
Author
30 Jun 2006 1:01 PM
reidarT
I have found the solution.
        Dim dteDato As String = (Me.txtDato.Text)
        Dim dteDato2 As String = "#" & Mid(dteDato, 4, 2) & "/" &
Mid(dteDato, 1, 2) & "/" & Mid(dteDato, 7, 4) & "#"
Then it works OK
Thanks for your help!
reidarT
Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> skrev i melding
news:eaGAJ$DnGHA.1248@TK2MSFTNGP05.phx.gbl...
> Reidar,
>
> I saw you changed your dateandtime already on your computer,
>
> However can you declare further, is this an insert commando from a
> dataadapter or just an insert commando for an executenonquery
>
> Cor
>
> "reidarT" <rei***@eivon.no> schreef in bericht
> news:uOAGiNCnGHA.4348@TK2MSFTNGP02.phx.gbl...
>>I got help from Cor L, but is not finished yet.
>>
>> In a windows form I need to add a date to a table in Access.
>>
>> Dim dteDato As Date = (Me.txtDato.Text)     ' I have tried Value instead
>> of Text, but it doesn't help
>> Dim con As New OleDb.OleDbConnection("Provider=Micr.....
>> Dim cmd As New OleDb.OleDbCommand("INSERT INTO tblToDo ( Dato ) SELECT "
>> & dteDato, con)
>> ...
>> The dteDato shows as #6/30/2006#
>> The table in access has the field as Date, Short date.
>> The message I get is Syntax error in number in query expression
>> 30.06.2006
>> (norwegian format)
>> I can't find ut what's wrong.
>> reidarT
>>
>
>
Author
2 Jul 2006 12:21 AM
Chris Chilvers
For formatting the date you could use this:

Dim dteDato As DateTime = DateTime.Parse(Me.txtDato.Text)
Dim dteDato2 As String = dteDato.ToString("#MM/dd/yyyy#")



Show quoteHide quote
On Fri, 30 Jun 2006 15:01:13 +0200, "reidarT" <rei***@eivon.no> wrote:

>I have found the solution.
>        Dim dteDato As String = (Me.txtDato.Text)
>        Dim dteDato2 As String = "#" & Mid(dteDato, 4, 2) & "/" &
>Mid(dteDato, 1, 2) & "/" & Mid(dteDato, 7, 4) & "#"
>Then it works OK
>Thanks for your help!
>reidarT
>"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> skrev i melding
>news:eaGAJ$DnGHA.1248@TK2MSFTNGP05.phx.gbl...
>> Reidar,
>>
>> I saw you changed your dateandtime already on your computer,
>>
>> However can you declare further, is this an insert commando from a
>> dataadapter or just an insert commando for an executenonquery
>>
>> Cor
>>
>> "reidarT" <rei***@eivon.no> schreef in bericht
>> news:uOAGiNCnGHA.4348@TK2MSFTNGP02.phx.gbl...
>>>I got help from Cor L, but is not finished yet.
>>>
>>> In a windows form I need to add a date to a table in Access.
>>>
>>> Dim dteDato As Date = (Me.txtDato.Text)     ' I have tried Value instead
>>> of Text, but it doesn't help
>>> Dim con As New OleDb.OleDbConnection("Provider=Micr.....
>>> Dim cmd As New OleDb.OleDbCommand("INSERT INTO tblToDo ( Dato ) SELECT "
>>> & dteDato, con)
>>> ...
>>> The dteDato shows as #6/30/2006#
>>> The table in access has the field as Date, Short date.
>>> The message I get is Syntax error in number in query expression
>>> 30.06.2006
>>> (norwegian format)
>>> I can't find ut what's wrong.
>>> reidarT
>>>
>>
>>
>