---------------------------------------------------------------------------
source = "server=(local); integrated security=SSPI; database=Northwind";
select = "select * from Customers";
Sqlconnection conn = new SqlConnection(source);
conn.Open();
SqlCommand cmd = new SqlCommand(select,conn);
int rowsReturned = cmd.ExecuteNonQuery(); //returns no of rows affected
---------------------------
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
ConsoleWriteline(reader[0], reader[1]); //returns a set of values
} // by iterating through records
-------------------------
object o = cmd.ExecuteScalar();
Console.WriteLine(o); // returns a column
-----------------
XmlReader xr = cmd.ExecuteXmlReader();
xr.Read(); // returns a XmlReaderObject
--------------
SqlDataAdapter da = new SqlDataAdapter(select, conn);
DataSet ds = new DataSet();
da.Fill(ds,"Customers"); //runtime schema generation
---------------------------------------------------------------------------
68 unique visitors
No comments:
Post a Comment