?
Solved

MS-Access vb.net 2008 interface

Posted on 2010-11-21
5
Medium Priority
?
304 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 1500 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 1500 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

762 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