Simple Query Dataset
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
class MainClass
{
[STAThread]
static void Main(string[] args)
{
DataSet dset = new DataSet();
string cstr = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI;";
using ( SqlConnection conn = new SqlConnection( cstr ) )
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter( "select * from Employee", conn );
da.Fill( dset, "Employee" );
}
foreach( DataRow dr in dset.Tables[ "Employee" ].Rows )
{
System.Console.WriteLine( "{0}", dr[ "firstName" ] );
}
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
|