Solved

MS-Access vb.net 2008 interface

Posted on 2010-11-21
5
303 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

696 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