natesh ghanta

natesh ghanta

  • NA
  • 32
  • 433

Please Reslove me from this error {"Cannot find table 0."}

Apr 4 2019 1:22 AM
  1. protected void btnsubmit_Click(object sender, EventArgs e)  
  2. {  
  3.     SqlConnection con = new SqlConnection(connectionString);  
  4.     con.Open();  
  5.     SqlCommand cmd = new SqlCommand("spGettblemployeeBydepartment", con);  
  6.     cmd.Parameters.AddWithValue("@commandtype""insert");  
  7.     int employeeid = Convert.ToInt32(cmd.ExecuteNonQuery());  
  8.     SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  9.     DataSet ds = new DataSet();  
  10.     //TextBox CategoryID = (TextBox)GridView1.Rows[0].FindControl("txtemployeeid");  
  11.     // cmd.Parameters.AddWithValue("employeeid", Convert.ToInt32(txtemployeeid));  
  12.     cmd.Parameters.AddWithValue("@employeename", Convert.ToString(txtemployeename.Text.Trim()));  
  13.     cmd.Parameters.AddWithValue("@departmentname", Convert.ToString(txtdepartmentname.Text.Trim()));  
  14.     cmd.Parameters.AddWithValue("@employeeaddress", Convert.ToString(txtemployeeaddress.Text.Trim()));  
  15.     //GridView1.DataSource = ds.Tables[1].DefaultView;  
  16.     Bindgrid();  
  17.     con.Close();  
  18.     //GridView1.DataSource = ds;  
  19.     //GridView1.DataBind();  
  20.     // DataSet ds = new DataSet();  
  21.     sda.Fill(ds);  
  22.     GridView1.DataSource = ds;  
  23.     //GridView1.DataMember = ds.Tables[0].TableName;  
  24.     GridView1.DataSource = ds.Tables[0];  
  25.     GridView1.DataBind();  
  26.   
  27. }  

Answers (3)