473,651 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you save a (C#) DateTime into a SQL Server datetime column?

Hi,

I have a table in a SQL Server 2005 database that has a column of type
"datetime". From a C# program I need to insert todays date into this
column like so:

gridAdapter.Ins ertNewGridID( Convert.ToDateT ime(DateTime.To day) );

I keep on getting an error: "Implicit conversion from data type
sql_variant to int is not allowed. Use the CONVERT function to run this
query."

How is this done?

Thanks in advance.
Steve

Aug 26 '06 #1
0 1123

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9323
by: Connie Sawyer | last post by:
I am trying to run the following query: ALTER TABLE dnb_profile ALTER COLUMN datetime and I keep getting the following error: Server: Msg 242, Level 16, State 3, Line 1 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
13
6733
by: TGEAR | last post by:
each table has a auditime field which keeps the last data who modified. I set this field as a datetime datatype and default value is getdate(), so the value is recorded like this 10/12/2004 7:28:02 AM. When I query to get that value, nothing showed up. I made a query as below select auditime from testtable where auditime = '10/12/2004 7:28:02 AM' but nothing was fetched. what did i do wrong?
4
8666
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 following INSERT statement: sqlDapter.InsertCommand = New SqlCommand sqlDapter.InsertCommand.CommandText = "INSERT INTO UserDetailss VALUES('bobby','simpson','" & Now() & "')" sqlDapter.InsertCommand.Connection = sqlConn sqlDapter.Update(dSet,...
5
1595
by: Steve Kershaw | last post by:
Hi I have a problem in that I need to save the creation date of a new record to a column. The column is set up as a datetime type and the C# date is a DateTime type. I keep on getting an error that states that I'm trying to write to a SQL column that's set up as an 'int'. Is there anyway to do this? Thanks very much for your help. Steve
4
7238
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which - "Modified" of type DateTime - is hidden since it should not be edited by a user. The system handles the update for this column. So, I have hidden (Visible=false) this column on the grid. In order to access the value in this field, I have created a...
6
30013
by: Manikandan | last post by:
Hi, I need to insert the datetime with milliseconds value into a datarow. My code as below DataTable testDataTable=new DataTable(); testDataTable.Columns.Add("updatedDateTime", typeof(DateTime)); DataRow testDateRow=surveyUpdatedDateDataTable.NewRow();
4
5578
by: Manikandan | last post by:
Hi, I'm inserting a datetime values into sql server 2000 from c# SQL server table details Table name:date_test columnname datatype No int date_t DateTime C# coding
2
3125
by: rhaazy | last post by:
I need to know how I can format a string in C# to get the current date/ time, so that I can do a comparison against a date time column in MS SQL Server 2005. The date/time column in the database is of the followin format: mm/dd/yyyy hh:mm:ss AM/PM thanks in advance.
0
2801
by: maolimix | last post by:
Hi to all, I have a trouble with datetime...now I explain.. I must to store to a C# variable the values from a "Datetime column" of Sql Server 2005. I tried 3 methods ...in the first two I never was able to get the Millisecond from datacolumn. I explain the methods... 1) I created a Datatable that contain the column... then I fill a datarow with the current value. The system automatically converts the Sqldatetime in System.Datetime but...
0
8275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8802
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8697
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.