|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DateTime problemI 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 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 > 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 >> > > 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 >>> >> >> >
String and int Issue
MDI Form loading Visual Basic 6.0, Enterprise Edition ASP.NET: VSNET2003 to VSNET2005 Global.asax.vb in Visual Studio .NET 2005 Question on XMLSerialization Comparing recordsets in VB2005 DirectX and False Stretching Images Writing ActiveX DLL in VB 2005 Datefield from variable into a datefield in an access b |
|||||||||||||||||||||||