I am creating a simple CRUD system in C#. While doing the project i ran into the problem with auto increment id of c#. I receive an error for this line:
int i = Mid(tmp, 3);
The error is "Mid doesn't exist in the current context".
How should I fix this?
public string AutoID()
{
SqlDataAdapter dr = new SqlDataAdapter("select pid from passanger", con);
dr.Fill(ds, "passanger");
dt = ds.Tables["passanger"];
int k = dt.Rows.Count;
if(k==0)
{
return "C0001";
}
else
{
DataRow r1 = dt.Rows[k - 1];
string tmp = r1["pid"].ToString();
int i = Mid(tmp, 3);
i = i + 1;
if(i<10)
{
return "C000" + i;
}
else if(i < 100)
{
return "C00" + i;
}
else if (i > 100)
{
return "C0" + i;
}
else
{
return "C0" + i;
}
}
}