asp.net - Login Page to verify NIC number -


i facing followingj problem: have database on access 2010 fields nic,active , page, of number types. want create login page takes nic (numeric) input user , redirects them specific page per nics.

different people see different pages.. getting error in executescalar command, maybe query not correct or maybe executescalar can't hold query... getting data type mismatch error.

try {     firsstpage f = new firsstpage();     secondpage second = new secondpage();     oledcon.open();      string nic = ( textbox1.text);     // string query = "select * logintable nic='" + nic + "'and active=0 , page=1";     //string query = "select * logintable nic='" + nic + "'and active=0";     string query = "select * logintable nic= '" + nic + "' , active=0 , page=1";     //string query = "select     oledbcommand comm = new oledbcommand( query,oledcon);     string = (string) comm.executescalar();     if (a != null)     {         response.redirect("firsstpage.aspx");         string update = "update logintable active='1' nic='" + nic + "' ";         //oledbcommand com = new oledbcommand();         //int b = convert.toint32( com.executescalar());     }     else     {         response.redirect("secondpage.aspx");         string update = "update logintable active='1' nic='" +nic + "' ";     }      oledcon.close(); } catch (exception ex) {     label1.text = ex.message; }  {     oledcon.close(); } 

problem using executescalar wrong query.

string = (string) comm.executescalar(); 

executescalar() return single value result query.

please change query query blow return single value database in place of entire colomn

select nic logintable nic= '" + nic + "' , active=0 , page=1"  

source :http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalar.aspx

i hope you.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -