VS.NET SQL Query Builder question

VS.NET SQL Query Builder question

Post by Bruce W. » Tue, 06 Aug 2002 11:47:27



Using C# in the code-behind...

The Visual Studio.NET SQL Query Builder does a great job of building basic SQL statements, like:
"SELECT * FROM Users"

But I want to insert a local variable into the statement.  So I go directly to the Web Form Designer generated code and insert my
variable, like this:

"SELECT * FROM users WHERE user_ID = " + num;  (where num is a local int)

This works a few times but then VS.NET blows it away and the program barfs.  The select statement is deleted, probably because I
messed directly with the Web Form Designer generated code.  I can accept that but I can't figure out how to put this into the
Query Builder directly.  It doesn't show the quotation marks and generates a bad statement with whatever I've tried.

Is there a way to do this WHERE modification to the SQL statement directly in the Query Builder?  Thanks for your help.

 
 
 

VS.NET SQL Query Builder question

Post by Jeff Loui » Tue, 06 Aug 2002 14:44:05


Bruce.... You can do:

SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address,
City, Region, PostalCode, Country, Phone, Fax FROM Customers WHERE

// Fill Customer data set using pKey_Customer

sqlDataAdapter1.Fill(dataSet12);

Jeff

Quote:>The Visual Studio.NET SQL Query Builder does a great job of building

basic SQL statements, like:
"SELECT * FROM Users"
But I want to insert a local variable into the statement.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

VS.NET SQL Query Builder question

Post by Bruce W. » Wed, 07 Aug 2002 01:14:06



> Bruce.... You can do:

> SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address,
> City, Region, PostalCode, Country, Phone, Fax FROM Customers WHERE

> // Fill Customer data set using pKey_Customer

> sqlDataAdapter1.Fill(dataSet12);

> Jeff

================================================================

I didn't mention that I'm using an OleDbAdapter to a MS Access database.  
Your reply did lead my in the right direction (parameter).  
The Query Builder seems to like a "?".  It generated this code
(which I hate to tamper with):

this.oleDbSelectCommand2.CommandText = "SELECT * FROM Users WHERE (user_ID = ?)";

this.oleDbSelectCommand2.Connection = this.oleDbConnection2;

this.oleDbSelectCommand2.Parameters.Add(new System.Data.OleDb.OleDbParameter("user_ID", System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, false, ((System.Byte)(10)), ((System.Byte)(0)), "user_ID",
System.Data.DataRowVersion.Current, null));

This Parameters.Add signature is confusing.  How (or where) can I input my int variable into this?  Thanks.

 
 
 

1. "data environment"/shaped query builder in vs.net: where is it?

I've started building hierarchical recordsets (shaped queries), which have a
somewhat tedious syntax. I would prefer to use a tool to build the queries.
Looking over the newsgroup archives, it's clear that this was possible in
VS6 using something called the data environment. It isn't clear to me how to
access this feature in VS.NET. Can anyone fill me in?

I'm a rank beginner with VS.NET, so please try to keep that in mind in your
explanation.

I'm using SQL Server 2k alongside VS.NET.

Many thanks for your help.

2. Why do some applications use a different color gray background in Win2k but not NT/9x????

3. Data Environment - SQL OLEDB Conn - Field List not Showing in Query Builder

4. NT named pipe security

5. SQL Query Builder

6. best game ever written (Rescue Raiders, of course!)

7. VS.NET SQL Editor is way behind Query Analyzer

8. SOAP again :-)

9. Query Builder SQL Problem

10. sql query builder/parser

11. Query Builder in Dataform wizard Question

12. Basic Query Builder question

13. Newbie questions VB.NET/ MSSQL SQL Query