A
Adam
Hi
I have problem with:
I would like that DataView read from DataBaza "lastname"
But I don't now how do it
My code is
Collection CreateDataSource()
{
String strConn = "DATABASE=Northwind;SERVER=localhost;UID=sa;PWD=;";
SqlConnection conn = new SqlConnection(strConn);
String strCmd = "SELECT * FROM Employees ";
SqlCommand cmd = new SqlCommand(strCmd, conn);
conn.Open();
SqlDataReader dr1 = cmd.ExecuteReader();
dr1.Read();
//MoreInfo.Text = BuildMoreInfoText(dr);
/////////////////////////////////////////////
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
for (int i = 0; i < 5; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
dr1.Close();
conn.Close();
Please, help me
I have problem with:
I would like that DataView read from DataBaza "lastname"
But I don't now how do it
My code is
Collection CreateDataSource()
{
String strConn = "DATABASE=Northwind;SERVER=localhost;UID=sa;PWD=;";
SqlConnection conn = new SqlConnection(strConn);
String strCmd = "SELECT * FROM Employees ";
SqlCommand cmd = new SqlCommand(strCmd, conn);
conn.Open();
SqlDataReader dr1 = cmd.ExecuteReader();
dr1.Read();
//MoreInfo.Text = BuildMoreInfoText(dr);
/////////////////////////////////////////////
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
for (int i = 0; i < 5; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
dr1.Close();
conn.Close();
Please, help me