Dear all,
I want to save my data into MS Access database Table which consist of
some fields with short date and short time formats.
I try to save data in to the said table and I am getting error that my
SQL statment is not correct.
string strSQL = @"INSERT INTO Activities ( Task,Day,Start,Finish )
VALUES ( '"+id+"', '"+date+"', '"+start+"', '"+finish+"' )" ;
I think error is because i am not able to cast my variables correctly.
how can i convert my DateTime to short date and short Time formats???
regards,
Omer kamal 3 15802
Omar,
Use parameters (the rest should go automatic) http://msdn.microsoft.com/library/de...eterstopic.asp
Be aware that you have in OleDb to add the parameters in the sequents of
occurence of your SQL string
I hope this helps,
Cor
"Omer kamal" <om**@rhrk.uni-kl.de> schreef in bericht
news:dg**********@news.uni-kl.de... Dear all,
I want to save my data into MS Access database Table which consist of some fields with short date and short time formats. I try to save data in to the said table and I am getting error that my SQL statment is not correct.
string strSQL = @"INSERT INTO Activities ( Task,Day,Start,Finish ) VALUES ( '"+id+"', '"+date+"', '"+start+"', '"+finish+"' )" ;
I think error is because i am not able to cast my variables correctly.
how can i convert my DateTime to short date and short Time formats???
regards,
Omer kamal
Omer kamal <om**@rhrk.uni-kl.de> wrote: I want to save my data into MS Access database Table which consist of some fields with short date and short time formats. I try to save data in to the said table and I am getting error that my SQL statment is not correct.
string strSQL = @"INSERT INTO Activities ( Task,Day,Start,Finish ) VALUES ( '"+id+"', '"+date+"', '"+start+"', '"+finish+"' )" ;
I think error is because i am not able to cast my variables correctly.
how can i convert my DateTime to short date and short Time formats???
The trick is not to embed the values directly in the SQL in the first
place. Instead, use aparameterised command. See http://www.pobox.com/~skeet/csharp/faq/#db.parameters
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
You should also be aware that date values are stored differnrtly in MS
Access, but the libray has methoids to convert both ways.
See:
DateTime.ToOADate Method
DateTime.FromOADate Method
Paul V. Sullivan
On Mon, 12 Sep 2005 05:55:35 +0200, Omer kamal <om**@rhrk.uni-kl.de>
wrote: Dear all,
I want to save my data into MS Access database Table which consist of some fields with short date and short time formats. I try to save data in to the said table and I am getting error that my SQL statment is not correct.
string strSQL = @"INSERT INTO Activities ( Task,Day,Start,Finish ) VALUES ( '"+id+"', '"+date+"', '"+start+"', '"+finish+"' )" ;
I think error is because i am not able to cast my variables correctly.
how can i convert my DateTime to short date and short Time formats???
regards,
Omer kamal This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sorisio, Chris |
last post by:
Ladies and gentlemen,
I've imported some data from a MySQL database into a Python dictionary. I'm
attempting to tidy up the date fields, but I'm receiving a
'mx.DateTime.Error: cannot convert...
|
by: goochey |
last post by:
I'm trying to convert a Julian Date (Format "4365") into an actual calendar
date in Visual Basic, can anyone help me out with this.
|
by: simon |
last post by:
I have datetime variable:
Datetime tsEndTime;
Should I use (DateTime):
tsEndTime=(DateTime)rdr.GetValue(15)
or is better to use:
tsEndTime=Convert.ToDateTime(rdr.GetValue(15))
|
by: Rob Roberts |
last post by:
I have a GridView that is bound to a collection of DateTimes (i.e. -
Collection<DateTime>). I have a BoundField in the GridView, and its
DataField is set to the DateTime's Date property, and the...
|
by: Terry Jolly |
last post by:
New to C# ---- How do I convert a Date to int?
In VB6:
Dim lDate as long
lDate = CLng(Date)
In C#
|
by: aqmaiya |
last post by:
Hello,
there is string value 'Dec 06, 2000' I want to convert that string
date to SHORT FORMAT like '2000-12-06-. Please help me how do I do
that? I'm new in Jython.
Thanks,
aqmaiya
|
by: kirke |
last post by:
Hi,
I have a datetime column named dtDateTime.
its format is "Oct 27 2006 12:00:00 "
I want to group by only date part of it and count
my code is
$sql1="SELECT ...
|
by: RSH |
last post by:
Hi,
I have a situation where I am using a dataset from a SQL Query. SQL's
DateTime is a "long date/time field" which includes the Date/Time. My
fields need to be displayed in a short time...
|
by: =?Utf-8?B?YW5kcmV3?= |
last post by:
I am running an ASP.net program written in VB. At one point I try to convert
a date string into a date time object... this string is from a central dev
server and the code works on many other...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
| |