473,385 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Date field in Access and datetimepicker in C#

SALAM = Hello
I can't move the value of a DateTimePicker in my C# application, to a field in a Access table which is Date format.
Actually when I inser the record it gives me this error message:
"Syntax error in INSERT INTO statement."

and I'v found problem is on date fields.

what's ur idea?

thx
Sep 5 '07 #1
4 5409
Shashi Sadasivan
1,435 Expert 1GB
SALAM = Hello
I can't move the value of a DateTimePicker in my C# application, to a field in a Access table which is Date format.
Actually when I inser the record it gives me this error message:
"Syntax error in INSERT INTO statement."

and I'v found problem is on date fields.

what's ur idea?

thx
check the syntax on how u insert the datetime field. usually for access i think it shoud be sourrounded by #
Sep 5 '07 #2
Actually I'm doubted about something. the value of dateTimepicker include date and time. but a DATE format in Access is pure date.
Mabe i should somehow filter the value of dateTimePicker to extract date part of that.
here is related parts of my code:

queryString = "INSERT INTO ProductSubjects (PSCode, PSName, PSDescription, CustomerID, , PSBeginDate, PSEndDate) " +
"VALUES (? , ? , ? , ? , ? , ?)";

OleDbParameter p1 = new OleDbParameter();
command.Parameters.Add(p1);
p1.Value = ps + code.ToString();
.
.
.
OleDbParameter p5 = new OleDbParameter();
command.Parameters.Add(p5);
p5.Value = dateTimePicker1.Value;

OleDbParameter p6 = new OleDbParameter();
command.Parameters.Add(p6);
p6.Value = dateTimePicker2.Value;

command.CommandText = queryString;
Int32 records = command.ExecuteNonQuery();
Sep 6 '07 #3
Dear Shashi,
your idea didn't work.

thx
Sep 6 '07 #4
Normally INSERTING DATE in Databases sometimes creates problem
try follow the Default format ("mm/dd/yyyy") in insertion.

Try debuging the SQL by writing SQL Insert script in Access with values that you get from Application.
Sep 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's...
7
by: XmlAdoNewbie | last post by:
Hi All, I am wondering if it is possible to allow nulls or empty strings when it comes to the datetimepicker control. I have an app with a few datetimepickers on it and there are some instances...
3
by: Sam | last post by:
Hi, I store the date selected in a datetimepicker into a sqlserver table in a SmallDateTime field. To be compatible with the date format of my sql server, I convert the date as following: Dim...
1
by: toufik | last post by:
Hi, VB.net project with ms-access database, I've a DATETIME field that I like to bind in my Form, it ontains the date only : - If I use a TextBox the problem is that There is an hour (12:00) added...
7
by: Jerome | last post by:
Hallo, I know a lot has already been told about date/time fields in a database but still confuses me, specif when dealing with SQLserver(Express). It seems that sqlserver only accepts the date in...
2
by: Darhl Thomason | last post by:
I'm converting my Access 2003 VBA app. I have a number of date fields in my db that I want to use the date/time picker control with, but if there is no entry in my database, I want the date/time...
5
by: M Skabialka | last post by:
I am creating my first Visual Studio project, an inventory database. I have created a form and used written directions to add data from a table to the form using table adapters, data sets, etc. ...
2
by: Claes Wedin | last post by:
My customer needs a DateTimePicker in VS2005 C# that can show emty date values (blank/space/null). I need a control that: 1. Can show a blank value 2. Detete a date when hitting the delete...
3
by: Finn Stampe Mikkelsen | last post by:
Hi I have defined a table in my database, with 2 date-fields. I have set a default value to DBNull. I have integrated a nullable datetimepicker control to my project and set the apropriate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.