I am trying to auto generate id in the webpage it gives me cannot find table o(Index out of Range Exception)
public int generateid()
{
int id = 0;
DataSet ds = new DataSet();
string constring = null;
SqlConnection conn = null;
try
{
constring = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
conn = new SqlConnection(constring);
conn.Open();
SqlCommand cmd = new SqlCommand("spAutoGeneratecustomerId1", conn);
cmd.CommandType = CommandType.StoredProcedure;
// SqldataAdapter da = new SqldataAdapter(cmd);
id = Convert.ToInt32(ds.Tables[0].Rows[0]["Customer_id"].ToString());
}
catch (Exception ex)
{
Console.WriteLine("Error" + ex.Message);
}
return id;
}
#business logic layer public partial class Test : System.Web.UI.Page
{
Business bal = new Business();
protected void Page_Load(object sender, EventArgs e)
{
txtId.Text = bal.getId().ToString();
}