|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Date/Time problemI've created a class With a few properties of type "date". I also have a SQL-database (which I can't change) with columns of type "datetime" when I use ... clsInfo.date = now() .... I can't pas the date to the database without errors... When I create a date property of type string and I use it like this ... clsInfo.dateString = "2006-12-2" .... it works fine... Anyone any idea's ? Do I have to convert the date to string before sending it to the database ? thanx John Hello John,
There's no need to convert it to string.. Dim tConnection As SqlConnection = New SqlConnection("connection string here") Dim tCommand as SqlCommand = New SQlCommand With tCommand .Connection = tConnection .CommandType = CommandType.Text .CommandText = "INSERT INTO someTable (dateField) VALUES (@dateValue) .Parameters.AddWithValue("@dateValue", Now) End With tConnection.Open tCommand.ExecuteNonQuery tConnection.Close Enjoy, -Boo Show quoteHide quote > Hi, > > I've created a class With a few properties of type "date". > I also have a SQL-database (which I can't change) with columns of type > "datetime" > when I use ... > > clsInfo.date = now() > > ... I can't pas the date to the database without errors... > > When I create a date property of type string and I use it like this > ... > > clsInfo.dateString = "2006-12-2" > > ... it works fine... > > Anyone any idea's ? Do I have to convert the date to string before > sending it to the database ? > > thanx > > John > In addition to Boo,
As you have done it correct of course and your DateTime is a real DateTime field in your database and not a string as sometimes is done. Cor Show quoteHide quote "GhostInAK" <ghosti***@gmail.com> schreef in bericht news:be1391bf15dbd8c899a680582a6f@news.microsoft.com... > Hello John, > > There's no need to convert it to string.. > > Dim tConnection As SqlConnection = New SqlConnection("connection string > here") > Dim tCommand as SqlCommand = New SQlCommand > > With tCommand > .Connection = tConnection > .CommandType = CommandType.Text > .CommandText = "INSERT INTO someTable (dateField) VALUES (@dateValue) > .Parameters.AddWithValue("@dateValue", Now) > End With > > tConnection.Open > tCommand.ExecuteNonQuery > tConnection.Close > > > Enjoy, > -Boo > >> Hi, >> >> I've created a class With a few properties of type "date". >> I also have a SQL-database (which I can't change) with columns of type >> "datetime" >> when I use ... >> >> clsInfo.date = now() >> >> ... I can't pas the date to the database without errors... >> >> When I create a date property of type string and I use it like this >> ... >> >> clsInfo.dateString = "2006-12-2" >> >> ... it works fine... >> >> Anyone any idea's ? Do I have to convert the date to string before >> sending it to the database ? >> >> thanx >> >> John >> > >
How to use this service ??? WSDL available
Writing text to file How to dynamically instantiate a base calss (w/ args to constructor?) Listview deselect all Crystal Reports for .NET 2005 secuity issue with terminal services connection? No equivalent control Getting Data out of MS Project rgb colors in vb.net string process ASCIIEncoding.GetString returns different values |
|||||||||||||||||||||||