Solved

MS-Access vb.net 2008 interface

Posted on 2010-11-21
5
301 Views
Last Modified: 2012-05-10
Can someone please help me i am trying to take the current date time from the system and write it into a access database together with some data i read in on my serial port.attatched find my command string. the problem is the data i get for the date part in access is corrupt

access data:"1900/01/07 04:49:52 PM" it is supposed to be "2010/11/21 09:02:08 PM" can someone please give me some pointers

Thank you
Andre
Dim date1 As Date = Date.Today
            str = "insert into table1 values(" & date1 & ",'" & TimeOfDay & "','" & UnitNumber & "','" & TempValue & "')"

Open in new window

0
Comment
Question by:Andre_p
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
Barsham earned 500 total points
ID: 34184451
what is the problem exactly ?
1- When you get Date&Time in MS-ACCESS it's wrong ?
OR 2- When you run your own query to insert your desired DATE&Time to MS-ACCESS some thing is wrong ?
0
 

Author Comment

by:Andre_p
ID: 34185872
My data if i open access is written as 1900/01/07 and not 2010/11/22. I use VB.net 2008 to write data into access. it i put a breakpoint into my program the date is written in vb as 11/22/2010, i exspect this is the problem as access is setted up to acsept it as 2010/11/22. hopes this clarify the problem
0
 
LVL 5

Assisted Solution

by:Barsham
Barsham earned 500 total points
ID: 34187299
It's always better to use parameter when you want to pass some values to SQL commands in your case you can get idea from the following codes :

please let me know if you have difficulty to understand the code.
Dim olddbCmd As New OleDb.OleDbCommand("INSERT INTO `Table1` (`Field1`, `BornDate`) VALUES (?, ?)")
olddbCmd.Parameters.Add("Field1", OleDb.OleDbType.WChar, 255)
olddbCmd.Parameters.Add("BornDate", OleDb.OleDbType.Date)
olddbCmd.Parameters(0).Value = "Value1"
olddbCmd.Parameters(1).Value = Date.Now

Open in new window

0
 

Author Comment

by:Andre_p
ID: 34190843
Thank you for the help i tried it but my insert statment stopped completly, after a lot of thinkering all that was fault at the end was the date was missing two ' signs . again thanks for the help
0
 

Author Closing Comment

by:Andre_p
ID: 34190861
Was not the sullution but led me in right direction
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question