Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using variable in an insert statement

Reply
Thread Tools

Using variable in an insert statement

 
 
=?Utf-8?B?SnVzdGlu?=
Guest
Posts: n/a
 
      11-09-2004
I have the following insert statement:

"INSERT INTO Queue(CustomerId, Status, QueueId, Type, January) VALUES
(@CustomerId" + ", @Status, @QueueId, @Type, @January); SELECT uId,
CustomerId, Status, QueueId, " + "Type, January FROM Queue WHERE (uId =
@@IDENTITY)";

this.sqlInsertCommand1.Parameters.Add("@January",
System.Data.SqlDbType.VarChar, 10, "January").Value =
ItemQueue.Items.ToString();

Where you see "January" I would like to pass a vaiable depending o the month
selected.

How can I accomplish this task?

Thanks, Justin.
 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      11-09-2004
You should use ADO.NET parameter objects. In addition to solving your
problem they will protect you against SQL Injection Attacks.

Here's more info:
http://msdn.microsoft.com/library/de...classtopic.asp
http://msdn.microsoft.com/library/de...isualbasic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Justin" <> wrote in message
news:3CCF3547-B0C4-4C3D-A1A1-...
>I have the following insert statement:
>
> "INSERT INTO Queue(CustomerId, Status, QueueId, Type, January) VALUES
> (@CustomerId" + ", @Status, @QueueId, @Type, @January); SELECT uId,
> CustomerId, Status, QueueId, " + "Type, January FROM Queue WHERE (uId =
> @@IDENTITY)";
>
> this.sqlInsertCommand1.Parameters.Add("@January",
> System.Data.SqlDbType.VarChar, 10, "January").Value =
> ItemQueue.Items.ToString();
>
> Where you see "January" I would like to pass a vaiable depending o the
> month
> selected.
>
> How can I accomplish this task?
>
> Thanks, Justin.



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Using a SQL statement with variable parameters and variable criteria Froefel ASP .Net 1 07-04-2007 09:38 AM
Saving BLOB data using C++ In one insert statement into Oracle mrkrishnan.ms@gmail.com C++ 2 01-19-2006 09:57 AM
Problems with insert statement using SSL(Verisign) mvr ASP General 0 03-03-2005 04:18 PM
Problems with insert statement using SSL(Verisign) mvr ASP General 2 03-01-2005 09:04 PM
INSERT statement contains fewer items than the insert list J. Muenchbourg ASP General 3 09-30-2003 08:58 PM



Advertisments