Date and oledb

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Sep 2008
Posts: 10
Reputation: mugun has a little shameless behaviour in the past 
Solved Threads: 0
mugun mugun is offline Offline
Newbie Poster

Date and oledb

 
0
  #1
Oct 3rd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Date and oledb

 
0
  #2
Oct 4th, 2008
What error message do you get?

Does this work in your code:
  1. Dim oConn As OleDbConnection
  2. Dim oCmd As OleDbCommand
  3. Dim strSQL As String
  4. Dim myDate As Date
  5.  
  6. myDate = CDate("4.10.2008") ' Use your locale date format, like "10/4/2008"
  7. strSQL = "INSERT INTO <mytable> (<my date field>) VALUES ('" & myDate & "')"
  8. oConn = New OleDbConnection("<your connectionstring")
  9. oConn.Open()
  10. oCmd = New OleDbCommand(strSQL, oConn)
  11. oCmd.ExecuteNonQuery()
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC