DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   Date and oledb (http://www.daniweb.com/forums/thread148981.html)

mugun Oct 3rd, 2008 5:09 pm
Date and oledb
 
I need help,i have a problem,i cant seem to insert from my vb interface to my access database...for example the access field is a fate type......how am i supposed to do it?,like if i enter my date like 24/2/08,it ll go in database,i tried my oledb.varchar,oledb.dbdate also does not work....can some1 help me out with this...everytime i use it i get error in insert into statement

Teme64 Oct 4th, 2008 5:38 am
Re: Date and oledb
 
What error message do you get?

Does this work in your code:
Dim oConn As OleDbConnection
Dim oCmd As OleDbCommand
Dim strSQL As String
Dim myDate As Date

myDate = CDate("4.10.2008") ' Use your locale date format, like "10/4/2008"
strSQL = "INSERT INTO <mytable> (<my date field>) VALUES ('" & myDate & "')"
oConn = New OleDbConnection("<your connectionstring")
oConn.Open()
oCmd = New OleDbCommand(strSQL, oConn)
oCmd.ExecuteNonQuery()


All times are GMT -4. The time now is 2:35 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC