asp.net - Incorrect syntax near '-' -


can me code ?! have problems when submit infos, can not add database.this created log-in form add infos , stuff not working can take @ code maybe find bug.

$

protected void page_load(object sender, eventargs e) {     if(ispostback)     {          sqlconnection conn = new sqlconnection(configurationmanager.connectionstrings["registerconnectionstring"].connectionstring);         conn.open();         string checkuser = "select count(*) userdatat username='" +textboxun.text + "'";         sqlcommand com = new sqlcommand(checkuser, conn);         int temp = convert.toint32(com.executescalar().tostring());         if (temp == 1)         {              response.write("ky user egziston");          }           conn.close();     } } protected void button1_click(object sender, eventargs e) {     try     {         sqlconnection conn = new sqlconnection(configurationmanager.connectionstrings["registerconnectionstring"].connectionstring);          conn.open();          string insertquery = "insert userdatat (username,e-mail,password,shteti) values (@uname ,@email ,@password ,@shteti)";         sqlcommand com = new sqlcommand(insertquery, conn);         com.parameters.addwithvalue("@uname", textboxun.text);         com.parameters.addwithvalue("@email", textboxem.text);         com.parameters.addwithvalue("@password", textboxpw.text);         com.parameters.addwithvalue("@shteti", dropdownlist1.selecteditem.tostring());          com.executenonquery();          response.redirect("manager.aspx");         response.write("regjistrimi eshte bere me sukses");            conn.close();     }     catch (exception ex)     {         response.write("error:" + ex.tostring());     } 

$

e-mail not valid identifier in sql. speaking it's best avoid creating column names this, however, if you're stuck column name, try delimiting identifier this:

string insertquery = "insert userdatat (username,[e-mail],password,shteti) values (@uname ,@email ,@password ,@shteti)"; 

but personally, prefer delimit all table or column names in sql queries matter of style, because helps more identify various parts of query, this:

string insertquery = "insert [userdatat] ([username],[e-mail],[password],[shteti]) values (@uname ,@email ,@password ,@shteti)"; 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -