473,396 Members | 1,968 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,396 software developers and data experts.

How to insert the date in DB using the dataset

Hi
I am trying to insert the data in the DB(sql server2005) using the dataset. I was trying to insert the data using the stored procedures.The problem is I am unable to insert the 'date' in the DB.

It shows an error as "Cannot convert from 'int' to 'System.DateTime' ". plz anyone help me if u know the answer.

Thanks & Regards,
kani.z
May 26 '08 #1
3 1172
CyberSoftHari
487 Expert 256MB
This error shows you that you are trying to (convert int to date time) insert int value to typeof datetime field. It will be easy to find only you post the code from insert part.
May 26 '08 #2
This error shows you that you are trying to (convert int to date time) insert int value to typeof datetime field. It will be easy to find only you post the code from insert part.
This is the code I have written in class file.
The class name is Corporate.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Corporate
/// </summary>
public class corporate
{
public corporate()
{
CorporateTableAdapters.CorporateTableAdapter cta = new CorporateTableAdapters.CorporateTableAdapter();
Corporate.CorporateDataTable cdt;
cdt = cta.GetDataByinsertCorporate("pizzahut", "raja", 2365412, "raja@gmail.com", "123456",6/26/2005, 6/26/2005, 6 / 26 / 2005, 1, 6/ 26 / 2006, 1, 6 / 26 / 2006);
}
}

This is the code I am trying to insert the data in the Corporate table. but the error occured as "cannot convert from 'int' to 'System.DateTime' " plz help me if u know the solution.

Thanks & Regards,
kani.z
May 26 '08 #3
Curtis Rutland
3,256 Expert 2GB
Put single quotes around your dates. The Sql engine is trying to integer divide the numbers you provide, and then insert the result as a date. It can't make that cast. It can cast a datetime from a string though.

This is the code I have written in class file.
The class name is Corporate.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Corporate
/// </summary>
public class corporate
{
public corporate()
{
CorporateTableAdapters.CorporateTableAdapter cta = new CorporateTableAdapters.CorporateTableAdapter();
Corporate.CorporateDataTable cdt;
cdt = cta.GetDataByinsertCorporate("pizzahut", "raja", 2365412, "raja@gmail.com", "123456",6/26/2005, 6/26/2005, 6 / 26 / 2005, 1, 6/ 26 / 2006, 1, 6 / 26 / 2006);
}
}

This is the code I am trying to insert the data in the Corporate table. but the error occured as "cannot convert from 'int' to 'System.DateTime' " plz help me if u know the solution.

Thanks & Regards,
kani.z
May 26 '08 #4

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

Similar topics

5
by: SSP | last post by:
Dear ASP.NETers, How would I insert multiple rows of data from a web form? Are there any tute's and stuff around. Couldn't find any myself. Thanks in advance. SSP
3
by: | last post by:
I have a datetime field in table. I want to insert the current time of database server to the table thr ASP.NET (C#). I have dataset to do the insert: DataSet1.TableNameRow rowNew =...
14
by: Samy K | last post by:
I'm having a bit of problems entering a new row to an access database and what I would like to know is do I have to assign certain values in my INSERT INTO SQL statement. I have read about the...
3
by: Ed | last post by:
Hi, I want to load data to a table in Sql Server from a dataset table in my vb.net app using a dataAdapter. I know how to do this as follows (my question is to see if I can reduce the amount...
0
by: Roman | last post by:
Hello, I am trying to insert xml data to SQL Server table. Everything works fine while the date field in xml file is not null. Once the date is null, <appt_date></appt_date>, I get...
6
by: Marcel Hug | last post by:
Hi all ! I have a table in my database, which has 3 attributes. IDFailureControl, ControlDate and ControlVersion. In the following function I test, if the date of today allready exists. Then I...
4
by: Arpan | last post by:
A SQL Server 2005 DB table has 4 columns namely "ID" (IDENTITY int column), "FirstName" (varchar(50)), "LastName" (varchar(50)) & "DOB" (datetime). Now when I am trying to add a new row using the...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
2
by: =?Utf-8?B?Y2F0?= | last post by:
We recently moved an older ASP.NET 1.1 code base on to ASP.NET 2.0, .NET 3.0 and Windows 2003 Server SP2. We started experiencing the following issue with the web cache (the code is straightforward...
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: 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...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.