473,378 Members | 1,207 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,378 software developers and data experts.

Build an SQL query without SqlCommand

I need to programatically change the SelectCommand of an
SqlDataSource. When I query I use SqlCommand and all the character
escaping is automatically done with SqlCommand.Parameters.Add(); Now,
since SelectCommand property is just a text, I need to manually do the
character escaping. Is there any other built-in query builder that I
can use in this situation?

Oct 27 '07 #1
1 1845
On 27 oct, 12:39, Sin Jeong-hun <typing...@gmail.comwrote:
I need to programatically change the SelectCommand of an
SqlDataSource. When I query I use SqlCommand and all the character
escaping is automatically done with SqlCommand.Parameters.Add(); Now,
since SelectCommand property is just a text, I need to manually do the
character escaping. Is there any other built-in query builder that I
can use in this situation?
What do you mean?, something like that

string sql = "select top 10 au_lname, phone from authors where
au_lname = 'White'";

(Note the single quotes)

However Parameters are the best practice, for security someone could
inject you database with dangerous code.
Regards.
Oct 27 '07 #2

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

Similar topics

10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
4
by: Kory | last post by:
How do you stop a long running query with a SQLConnection or SQLCommand? Calling Close on either just waits until the query is done. Is there a way to stop it? The following on a long query ...
11
by: anony | last post by:
Hello, I can't figure out why my parameterized query from an ASP.NET page is dropping "special" characters such as accented quotes & apostrophes, the registered trademark symbol, etc. These...
2
by: Howard | last post by:
How do I do this with parameterized query? without parameterized query: string search = "hello world search"; search = search.Replace(" ", " AND "); SELECT * FROM TABLE1 WHERE TEXT LIKE '%' +...
2
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
How can I run this query against a table in my Access database? I don't know hwo to use it in C#. In VB I would use .Recordset = "some sql statement". How do I do this in C#? //I get a vlaue...
2
by: weird0 | last post by:
Hi! On the recommendation of one of the MVP's on this group....... I tried writing parametrized queries. But the fucking thing does not work and it does not update the data in the table. I...
13
by: ofiras | last post by:
Is there a command to do a query for an SQL database? I managed to make a sql connection variable, and to take info from it by making a SqlDataAdapter with select query in it, and filling the...
0
by: Sin Jeong-hun | last post by:
I need to programatically change the SelectCommand of an SqlDataSource. When I query I use SqlCommand and all the character escaping is automatically done with SqlCommand.Parameters.Add(); Now,...
0
petepell
by: petepell | last post by:
Hello all, I am developing an application in VB 2008 that works with a SQL2005 DB to store and manipulate employee data. In one section of the app I want to be able to show a treeview of the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.