Hi all
I am currently learning asp .net and i'm struggling with it.
I am trying to create a admin.aspx form where administrators can go in and add new users to the system. bellow is my code
Admin.aspx.cs (code behind Add button)
private void addUserBt(object sender, System.EventArgs e)
{
//create an object to access dbconn.cs
dbConn connectTodb = new dbConn();
string cmd = "INSERT INTO users (username, password, name, permission, active) VALUES (usernameTxt, passwordTxt, nameTxt,,1)";
connectTodb.getConnected(cmd);
Console.WriteLine("Record Inserted");
}
now i have another class called dbConn where the connection happens
public void getConnected(string cmd)
{
string sqlString = @"Data Source = (local);initial catalog=Bugs; User Id =sa; Password = saadmin;";
SqlConnection sqlConn = new SqlConnection(sqlString);
sqlConn.Open();
SqlCommand sqlCmd = new SqlCommand(cmd);
SqlDataReader reader = sqlCmd.ExecuteReader();
}
everytime i run my app, nothing is inserted in the db
here are the columns in my db
users{user_id (auto, prmary key), username, password, name, permission, active}
cna anyone tell me where i'm going wrong
thanks in advance