Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS-Access vb.net 2008 interface

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

610 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