PC Review


Reply
Thread Tools Rate Thread

dates in dataadapter sql

 
 
John
Guest
Posts: n/a
 
      1st Aug 2003
Hi

I am looking for some examples of how to use dates in sql statement in the
dataadapter context.

Thanks

Regards


 
Reply With Quote
 
 
 
 
Michael Lang
Guest
Posts: n/a
 
      1st Aug 2003
Do you mean the format of the date in the SQL string?

The easy way is to not worry about typing the full SQL string. Use Command
objects with Parameters for each field.

SqlCommand cmdUpdate = new SqlCommand();
cmdUpdate.Connection = myConnection;
cmdUpdate.CommandText = new SqlCommand("UPDATE titles SET "
+ "title = @title"+ ", "
+ "type = @type"+ ", "
+ "pub_id = @pub_id"+ ", "
+ "price = @price"+ ", "
+ "advance = @advance"+ ", "
+ "royalty = @royalty"+ ", "
+ "ytd_sales = @ytd_sales"+ ", "
+ "notes = @notes"+ ", "
+ "pubdate = @pubdate"+ " WHERE title_id = @title_id");

.... add first parameters here...
SqlParameter prm9 = new SqlParameter("@pubdate" , SqlDbType.DateTime);
prm9.SourceColumn = "pubdate";
cmdUpdate.Parameters.Add(prm9);

Now make this the UpdateCommand on your DataAdapter.

Michael Lang, MCSD
Take a look at my open source database project code generator...
http://sourceforge.net/projects/dbobjecter

"John" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> I am looking for some examples of how to use dates in sql statement in the
> dataadapter context.
>
> Thanks
>
> Regards
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
difference between dataAdapter.InsertCommand/dataAdapter.SelectCom =?Utf-8?B?UmljaA==?= Microsoft VB .NET 3 10th Nov 2006 03:34 PM
DataAdapter Dragon Microsoft C# .NET 2 9th Mar 2006 04:40 PM
DataAdapter Stephen Noronha Microsoft ASP .NET 3 20th Sep 2005 12:10 AM
Dataadapter Andrew Cooper Microsoft VB .NET 6 7th Feb 2004 05:31 AM
SQL LIKE and the DataAdapter Jim Chapman Microsoft ADO .NET 2 14th Jul 2003 06:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:53 AM.