This is the error I get:
Index (zero based) must be greater than or equal to zero and less than the size of the argument list
This is the code:
<%@ Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE html>
<script runat="server">
public void Page_Load()
{
string a, c;
a = Request.Form["username"];
string connstring = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("SQL/Site_Database.accdb");
string sqlstring = string.Format("select * from iUsers_Table where (iusername='{0}')", a);
OleDbDataAdapter da = new OleDbDataAdapter(sqlstring, connstring);
DataSet ds = new DataSet();
da.Fill(ds);
c = Request.Form["mail"];
string connstring1 = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("SQL/Site_Database.accdb");
string sqlstring1 = string.Format("select * from iUsers_Table where (imail='{0}')", c);
OleDbDataAdapter da1 = new OleDbDataAdapter(sqlstring1, connstring1);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
if ((ds.Tables[0].Rows.Count == 0) || (ds1.Tables[0].Rows.Count == 0))
{
string b, d, e, f, g, h;
b = Request.Form["password"];
d = Request.Form["gender"];
e = Request.Form["age"];
f = Request.Form["prob"];
g = Request.Form["prob_val"];
h = Request.Form["fitness"];
sqlstring = string.Format("insert into iUsers_Table (iusername,ipassword,imail,igender,iage,iproblem,iproblem_value,ifitness) values('{0}','{1}','{2}','{3}',{4},'{5}',{6},'{7}')", a, b, c, d, e, f, g, h);
OleDbConnection conn = new OleDbConnection(connstring);
OleDbCommand cmd = new OleDbCommand(sqlstring, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Session["connect_status"] = "connected";
Response.Redirect("My_Plan.aspx");
}
else
{
if ((ds.Tables[0].Rows.Count) > 0)
{
Session["subscribed"] = "exist";
if ((ds1.Tables[0].Rows.Count) > 0)
{
Session["mail"] = "exist";
Response.Redirect("index.aspx");
}
Response.Redirect("index.aspx");
}
}
}
</script>
I created a sign up form and this code is used to insert the data into the database and check also for existing equal mail and username values.
Anyone know why this is happening?
Thank you!
ds.Tablesandds1.Tableshave at least one value? - Arturo Menchacaif (ds.Tables.Count > 0 && ds1.Tables.Count > 0)beforeif ((ds.Tables[0].Rows.Count == 0) || ...- Arturo Menchaca