2009/03/14
How to gather data from database in C# (backend)
Using a stored procedure with MS SQL Server.
[CODE]
string strConnection = String.Empty;
DataSet uniqueDS = new DataSet();
SqlDataAdapter uniqueDA;
strConnection = "'connection string'";
uniqueDA = newSqlAdapter(sp, strConnection);
uniqueDA.SelectCommand.CommandType =
CommandType.StoredProcedure;
uniqueDS = New DataSet;
uniqueDA.Fill(uniqueDS, "TABLE");
For direct access to the actual tables and rows and cells inside the dataset:
[CODE]
string =
uniqueDS.Tables("TABLE").Rows(RowIndex).Items(ColumnIndex).ToString;
Of course there are more ways... but this way is direct access to DataSet values.
//
sk0t @ 12:44 AM ::
Comments [2] ::
Digg This ::