Help

A

Adam

Hi I have code
It read from date base, table "lastname" the data and I would like
put to dr[0] - array
The code
{
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();
string lastName = string.Empty;
SqlDataReader dr1 = cmd.ExecuteReader();
dr1.Read();



/////////////////////////////////////////////
//DataTable dt = new DataTable();

// DataRow dr;

//dt.Columns.Add(new DataColumn("IntegerValue",
typeof(Int32)));
//dt.Columns.Add(new DataColumn("StringValue",
typeof(string)));

while(dr1.Read())
{
lastName=dr1["lastname"].ToSring());
}

But I have erron in 31 line
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: CS1002: ; expected

Help me
 
J

Jon Skeet [C# MVP]

while(dr1.Read())
{
lastName=dr1["lastname"].ToSring());
}

But I have erron in 31 line
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: CS1002: ; expected

Well, for one thing, you've got too many brackets on the line calling
ToString, and for another, it's ToString, not ToSring.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top