The syntax of the SQL commands created by VS.NET puzzle me. Hopefully you can offer a rational explanation.
Here is an example table, name myTable:
ValID (int, Identity, primary key)
Value (varchar(50))
From VS.NET toolbox, I select SqlDataAdapter. I enter the connection and ask it to generate SQL commands in the program. The SQL command I provide is:
Select * From myTable
Here are the SQL commands generated:
SelectCommand
SELECT ValID, Value FROM myTable
InsertCommand
INSERT INTO myTable(Value) VALUES (@Value);
SELECT ValID, Value FROM myTable WHERE (ValID = @@IDENTITY)
UpdateCommand
UPDATE myTable SET Value = @Value
WHERE (ValID = @Original_ValID) AND
(Value = @Original_Value OR @Original_Value IS NULL AND Value IS NULL);
SELECT ValID, Value FROM myTable WHERE (ValID = @ValID)
The Select command is perfectly understandable.
For the Insert command, what is the purpose of the Select statement?
For the Update command:
- Since ValID is guarenteed to be unique, why the complex WHERE clause?
- What is the purpose of the Select statement?
Thanks!
----
Gerry Roston
gerry@pairofdocs.net
Here is an example table, name myTable:
ValID (int, Identity, primary key)
Value (varchar(50))
From VS.NET toolbox, I select SqlDataAdapter. I enter the connection and ask it to generate SQL commands in the program. The SQL command I provide is:
Select * From myTable
Here are the SQL commands generated:
SelectCommand
SELECT ValID, Value FROM myTable
InsertCommand
INSERT INTO myTable(Value) VALUES (@Value);
SELECT ValID, Value FROM myTable WHERE (ValID = @@IDENTITY)
UpdateCommand
UPDATE myTable SET Value = @Value
WHERE (ValID = @Original_ValID) AND
(Value = @Original_Value OR @Original_Value IS NULL AND Value IS NULL);
SELECT ValID, Value FROM myTable WHERE (ValID = @ValID)
The Select command is perfectly understandable.
For the Insert command, what is the purpose of the Select statement?
For the Update command:
- Since ValID is guarenteed to be unique, why the complex WHERE clause?
- What is the purpose of the Select statement?
Thanks!
----
Gerry Roston
gerry@pairofdocs.net