473,385 Members | 2,004 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.

Sending command with DateTime

Hi,

I'm using SQLCmd = New SqlClient.SqlCommand and then
SQLCommand.CommandType = CommandType.Text

My problem is as follows: I like to update a table in SQL Server with a
column of the type DateTime.
so I used "UPDATE MyTable SET TheTime=" & ActualTime.ToString. But it's
not working. What is the way to send a DateTime datatype to SQL Server??

Thanks a lot

Steffen

Nov 18 '05 #1
2 976
1) Use parameter

sqlcmd.Parameters.Add([param name], sqldbtype.DateTime).Value = MyDate

2) Cast datetime to 'yyyyMMdd' format

"Update ... set TheTime = " & ActualTime.toString('yyyyMMdd')

HTH

"Steffen Loringer" <st**************@freenet.de> wrote in message
news:c0*************@ID-220178.news.uni-berlin.de...
Hi,

I'm using SQLCmd = New SqlClient.SqlCommand and then
SQLCommand.CommandType = CommandType.Text

My problem is as follows: I like to update a table in SQL Server with a
column of the type DateTime.
so I used "UPDATE MyTable SET TheTime=" & ActualTime.ToString. But it's
not working. What is the way to send a DateTime datatype to SQL Server??

Thanks a lot

Steffen

Nov 18 '05 #2
Hi, Steffen Loringer,

You should use parameters to avoid problems:

http://msdn.microsoft.com/library/en...etersTopic.asp

Hope this helps
Martin
"Steffen Loringer" <st**************@freenet.de> wrote in message
news:c0*************@ID-220178.news.uni-berlin.de...
Hi,

I'm using SQLCmd = New SqlClient.SqlCommand and then
SQLCommand.CommandType = CommandType.Text

My problem is as follows: I like to update a table in SQL Server with a
column of the type DateTime.
so I used "UPDATE MyTable SET TheTime=" & ActualTime.ToString. But it's
not working. What is the way to send a DateTime datatype to SQL Server??

Thanks a lot

Steffen

Nov 18 '05 #3

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

Similar topics

2
by: george | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, on an NT box, Active Server pages with Javascript, using ADO objects. ...
5
by: Naveen Mukkelli | last post by:
Hi, I'm writing a server applicaiton using C# and .NET Framework. This server sends out time to all the clients. The clients are expected to be written in various platforms for example, Delphi,...
1
by: Kenneth P | last post by:
Hi, I'm trying to do some Custom Paging technique with the datagrid object and with the select command in Sql, thus forcing the server to only select those rows from the database that should be...
6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: Buddy Home | last post by:
There is two examples of code. Example 1. Send and Receive within the same process. Put this code in a console app called SendAndReceive and run the code. using System; using...
6
by: Rushwire | last post by:
Does anybody know how to send a meeting request using an ics/vcs (VCalendar) attachment from an asp.net page. I don't want my users to have to double click on the attachment but rather that it is...
3
by: iKiLL | last post by:
Hi all I am having problems getting my SqlCeDataAdapter to Update the SQL Mobile Data base. i am using C# CF2. I have tried this a number of different ways. Starting with the command builder...
3
by: Sagar | last post by:
Hi. I am working on a project to migrate a web application from 1.1 to 2.0 Within in the DAL of the application, there is a call to below function that builds a command object for later use. ...
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: 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...
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...
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
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
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.