You are using a SELECT statement to fetch records from database.
But you have specified that the OdbcCommand.CommandType is StoredProcedure which is wrong. It should be Text type. Your code should look like as
protected void Page_Load(object sender, EventArgs e)
{
String constring = "Driver={MySQL ODBC 5.1 Driver};server=localhost;uid=root;database=db_dcii;port=3306";
DataTable dt = new DataTable();
OdbcConnection connection = new OdbcConnection(constring);
try
{
connection.Open();
OdbcCommand sqlCmd = new OdbcCommand();
sqlCmd.Connection = connection;
[B]sqlCmd.CommandType = CommandType.Text; [/B] sqlCmd.CommandText = "Select * from login";
OdbcDataAdapter sqlDa = new OdbcDataAdapter(sqlCmd);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
catch (Exception ex)
{
string msg = "Fetch Error:";
msg += ex.Message;
}
finally
{
connection.Close();
}
}
Also put a break point at dt.Rows.Count to see if it returns any records.