Solved

MS-Access vb.net 2008 interface

Posted on 2010-11-21
5
298 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
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
Barsham earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Was not the sullution but led me in right direction
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
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…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now