T
TreyH
The error is:
System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ','.
And occurs towards the bottom of this code snippet
What is causing this??
Thanks
(FYI - the code doesn't wrap like it's showing here)
string sText = "Select * from dbo.USERS_tbl where 1=0";
string strConn = "Data Source=localhost;Initial
Catalog=portal_sscc_testing;uid=startuser;Pwd=startuser;";
SqlConnection objConn = new SqlConnection(strConn);
SqlDataAdapter myDA = new SqlDataAdapter(sText, objConn);
string sInserttxt = myCommand.InsertCommand.CommandText;
myDA.InsertCommand = new SqlCommand(sInserttxt, objConn);
myDA.InsertCommand.CommandType = CommandType.Text;//.StoredProcedure;
myDA.InsertCommand.Parameters.Add("@UserName", SqlDbType.VarChar,
50, "UserName");
myDA.InsertCommand.Parameters.Add("@Password", SqlDbType.VarChar,
180, "Password");
myDA.InsertCommand.Parameters.Add("@UsrEmail", SqlDbType.VarChar,
150, "UsrEmail");
myDA.InsertCommand.Parameters.Add("@UsrPhone", SqlDbType.VarChar,
10, "UsrPhone");
objConn.Open();
DataSet myDs = new DataSet();
myDA.Fill(myDs, "user_tbl");
DataRow myRow = myDs.Tables["user_tbl"].NewRow();
myRow["UserName"] = txtUserName.Text;
myRow["Password"] = txtPassword.Text;
myRow["UsrEmail"] = txtEmail.Text;
myRow["UsrPhone"] = txtPhone.Text;
myDs.Tables["user_tbl"].Rows.Add(myRow);
myDA.Update(myDs, "user_tbl"); <===ERROR OCCURS HERE
[System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ','.]
objConn.Close();
System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ','.
And occurs towards the bottom of this code snippet
What is causing this??
Thanks
(FYI - the code doesn't wrap like it's showing here)
string sText = "Select * from dbo.USERS_tbl where 1=0";
string strConn = "Data Source=localhost;Initial
Catalog=portal_sscc_testing;uid=startuser;Pwd=startuser;";
SqlConnection objConn = new SqlConnection(strConn);
SqlDataAdapter myDA = new SqlDataAdapter(sText, objConn);
string sInserttxt = myCommand.InsertCommand.CommandText;
myDA.InsertCommand = new SqlCommand(sInserttxt, objConn);
myDA.InsertCommand.CommandType = CommandType.Text;//.StoredProcedure;
myDA.InsertCommand.Parameters.Add("@UserName", SqlDbType.VarChar,
50, "UserName");
myDA.InsertCommand.Parameters.Add("@Password", SqlDbType.VarChar,
180, "Password");
myDA.InsertCommand.Parameters.Add("@UsrEmail", SqlDbType.VarChar,
150, "UsrEmail");
myDA.InsertCommand.Parameters.Add("@UsrPhone", SqlDbType.VarChar,
10, "UsrPhone");
objConn.Open();
DataSet myDs = new DataSet();
myDA.Fill(myDs, "user_tbl");
DataRow myRow = myDs.Tables["user_tbl"].NewRow();
myRow["UserName"] = txtUserName.Text;
myRow["Password"] = txtPassword.Text;
myRow["UsrEmail"] = txtEmail.Text;
myRow["UsrPhone"] = txtPhone.Text;
myDs.Tables["user_tbl"].Rows.Add(myRow);
myDA.Update(myDs, "user_tbl"); <===ERROR OCCURS HERE
[System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ','.]
objConn.Close();