jedistar
asked on
SQL server, connection, command, reader, adapter etc.
Hi,
How do i create a sqlconnection using windows authentication?
How do i write the sqlcommand to retrieve data from the table "products" where id = 5?
How do i use a data reader to read data from the above?
How do i use a dataadapter to read from table "products", passing it into a Dataset?
How do i write stored procedures using VS.NET 2003 or SQL SERVER?
Lastly, what is a typed dataaset and whats the diff between a normal ds and typed ds?
How do i create a sqlconnection using windows authentication?
How do i write the sqlcommand to retrieve data from the table "products" where id = 5?
How do i use a data reader to read data from the above?
How do i use a dataadapter to read from table "products", passing it into a Dataset?
How do i write stored procedures using VS.NET 2003 or SQL SERVER?
Lastly, what is a typed dataaset and whats the diff between a normal ds and typed ds?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, just my first qn, you used:
"Integrated Security=SSPI;Data Source=localhost;Initial Catalog=Northwind;"
can i use this -> Server=localhost;Database= Northwind; Integrated Security=SSPI;
Or must they be used in groups
eg:
Group 1-> "Integrated Security=SSPI;Data Source=localhost;Initial Catalog=Northwind;"
Group 2-> "Server=localhost;Database =Northwind ;User ID=sa;Password='';
"Integrated Security=SSPI;Data Source=localhost;Initial Catalog=Northwind;"
can i use this -> Server=localhost;Database=
Or must they be used in groups
eg:
Group 1-> "Integrated Security=SSPI;Data Source=localhost;Initial Catalog=Northwind;"
Group 2-> "Server=localhost;Database
For the second syntax, use "Trusted_Connection=True" instead of "Integrated Security=SSPI"
So you can choose:
"Data Source=localhost;Initial Catalog=Northwind;Integrat ed Security=SSPI;"
- or -
"Server=localhost;Database =Northwind ;Trusted_C onnection= True;"
(both connection strings produces the same result)
The first syntax is what VS generates when you create a connection, so that's what I typically use.
So you can choose:
"Data Source=localhost;Initial Catalog=Northwind;Integrat
- or -
"Server=localhost;Database
(both connection strings produces the same result)
The first syntax is what VS generates when you create a connection, so that's what I typically use.
CREATE PROCEDURE GetProduct
@argProductID int
AS
SELECT * FROM Products WHERE ProductID = @argProductID
A Typed DataSet is a class that derives from DataSet that has defenitions for tables and type-safe properties for the columns of each table.
For example, a TypeDataSet for the Northwind database might have the following defenition for the Products table along with a bunch of other code:
public class NorthwindDataSet : DataSet
{
// Lost of DataSet management code
public class Products : DataTable
{
public int ProuctID
{
get
{
//
}
set
{
//
}
}
public string ProductName
{
get
{
//
}
set
{
//
}
}
// other properties for each column
}
}
These classes can be generated by adding a DataSet item to your project and dragging tables into it from the Server Explorer.