Can any bode explain me In this code, where do I put SQL info ( Username and Password) to the Server ?
string connectionstring = @"Data Source=sourcename;Initial Catalog=database;Integrated Security=True"; string query = "SELECT status FROM [table] WHERE username=@name and password=@pass"; //username and password are column names SqlConnection connection = new SqlConnection(connectionstring); //pass the query to db SqlCommand command = new SqlCommand(query,connection); //pass the user name and password command.parameters.AddwithValue("@password",passwordtextboxvalue); command.parameters.AddWithValue("@username",usernametextboxvalue); try { connection.Open(); string status=command.ExecuteNonQuery(); if(status==1) { //unload and load } else { //do something } } catch(Exception e) { //handle the exception }
- Edited by BeAwareAlien Saturday, October 12, 2013 7:47 AM
- Edited by Olaf HelperMVP, Editor Sunday, October 13, 2013 8:35 AM C# code format