Query Parameters

S

Shahid Juma

Hi,

I am using Microsoft Application Blocks and I have the following query.

//save the data
insertSQL = "INSERT INTO Table1 VALUES (" + unixTime + "," + CCR + ","
+ CCT + "," + CCT + ",'" + completedBy + "','" + id + "',100, 'test',
'test')";

SqlHelper.ExecuteNonQuery (objConnect, CommandType.Text, insertSQL);

Is there anyway to break up the above so it is cleaner and I just pass
the parameters instead of building the query? The above does do the
work but is not cleaner and I need to use the same query somewhere else
too.

Thanks for the help
Shahid
 
J

John

Shahid Juma said:
Hi,

I am using Microsoft Application Blocks and I have the following query.

//save the data
insertSQL = "INSERT INTO Table1 VALUES (" + unixTime + "," + CCR + ","
+ CCT + "," + CCT + ",'" + completedBy + "','" + id + "',100, 'test',
'test')";

SqlHelper.ExecuteNonQuery (objConnect, CommandType.Text, insertSQL);

Is there anyway to break up the above so it is cleaner and I just pass
the parameters instead of building the query? The above does do the

This doesn't really answer your questions, but in case you don't know,
THIS IS VER DANGEROUS IN A WEBAPP.

Go google "SQL Injection Attack"

Then use either a stored procedure or a parameterized query. You'll add
lines of code, but you'll sleep better knowing you aren't going to get sued
for incompetence. ;)

Regards,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top