G
Guest
Hi,
I am running the following code succesffuly on Windows XP, but it is giving
me problems on Windows 2003 server. On the latter, last_insert_id always
returns a 0!
cmdStr = "INSERT INTO users VALUES (NULL, '" + uemailTextbox.Text + "')";
cmd = new OdbcCommand(cmdStr, conn);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
conn.Close();
string uid = "";
cmdStr = "SELECT LAST_INSERT_ID()";
cmd = new OdbcCommand(cmdStr, conn);
cmd.Connection.Open();
if (cmd.ExecuteScalar() !=null)
uid = cmd.ExecuteScalar().ToString();
conn.Close();
if (uid.Length > 0)
{
cmdStr = "INSERT INTO cats VALUES (NULL, '" + uid + "')";
cmd = new OdbcCommand(cmdStr, conn);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
Thanks in advance.
-Shefali
I am running the following code succesffuly on Windows XP, but it is giving
me problems on Windows 2003 server. On the latter, last_insert_id always
returns a 0!
cmdStr = "INSERT INTO users VALUES (NULL, '" + uemailTextbox.Text + "')";
cmd = new OdbcCommand(cmdStr, conn);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
conn.Close();
string uid = "";
cmdStr = "SELECT LAST_INSERT_ID()";
cmd = new OdbcCommand(cmdStr, conn);
cmd.Connection.Open();
if (cmd.ExecuteScalar() !=null)
uid = cmd.ExecuteScalar().ToString();
conn.Close();
if (uid.Length > 0)
{
cmdStr = "INSERT INTO cats VALUES (NULL, '" + uid + "')";
cmd = new OdbcCommand(cmdStr, conn);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
Thanks in advance.
-Shefali