Torna al Thread

protected void btnRegister_OnClick(object sender, EventArgs e) { if (Page.IsValid) { OdbcConnection objConn = new OdbcConnection(connectionString); string strSQL2 = null; string strRole = "Utente"; string strSQL1 = null; strSQL1 = "SELECT * FROM Users "; OdbcCommand command = new OdbcCommand(strSQL1, objConn); // Execute the DataReader and access the data. OdbcDataReader reader = command.ExecuteReader(); while (reader.Read()) { //Console.WriteLine("CustomerID={0}", reader[0]); txtUsername.Text = "" + reader["username"] + ""; } // Call Close when done reading. reader.Close(); strSQL2 = "INSERT INTO Users (Fullname, Email, Username,Password,role,Info)"; strSQL2 = strSQL2 + " VALUES "; strSQL2 = strSQL2 + "('" + txtFullname.Text + "', '" + txtEmail.Text + "', '" + txtUsername.Text + "', '" + txtPassword.Text + "','" + strRole + "','" + txtInfo.Text + "')"; objConn.Open(); OdbcCommand addUser = new OdbcCommand(strSQL2, objConn); addUser.ExecuteNonQuery(); objConn.Close(); Response.Redirect("login.aspx"); objConn.Close(); } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5