2
Answers

Error in foreach loop.,

Bala

Bala

11y
1.1k
1

I tried to get data from database table(login_master)., i tried this in gridview but without  gridview how can i get this.



Here is the code, that is what i tried now to reach the requirement :

<%
SqlConnection dbconn;
SqlDataAdapter objAdapter;
DataTable  objTable;
DataRow objRow;
DataSet objDataSet =new DataSet();
dbconn=new SqlConnection("Data Source  = E-SOFT-5; Initial Catalog = attend; User Id = sa; Password = e-soft");
objAdapter=new SqlDataAdapter("SELECT * FROM login_master",dbconn);
objAdapter.Fill(objDataSet,"login_master");
objTable=objDataSet.Tables.Add("login_master");
objRow=objTable.Rows.Add(0);
Response.Write ("<table border='1'>");
Response.Write("<tr><th>Email</th><th>Name</th><th>Emp_password</th></tr>");
foreach(string[] x in objTable.Rows)
{
      Response.Write("<tr>");
      Response.Write("<td>" & x("Email") & "</td>");
        Response.Write("<td>" & x("Name") & "</td>");
        Response.Write("<td>" & x("Emp_password") & "</td>");
      Response.Write("</tr>") ;
}

Response.Write("</table>");
dbconn.Close();
%>



Error is:  x is a variable but you used like a method in for loop.

Answers (2)
Next Recommended Forum