try { string conStr = WebConfigurationManager.ConnectionStrings[0].ConnectionString; SqlDataAdapter adapter; DataTable ans = new DataTable(); SqlConnection connection = new SqlConnection(conStr); SqlCommand command = new SqlCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "usp_GetUserDetails"; command.Parameters.Add("@UserName", SqlDbType.VarChar); command.Parameters.Add("@Password", SqlDbType.VarChar); command.Parameters["@UserName"].Value = user; command.Parameters["@UserName"].Direction = ParameterDirection.Input; command.Parameters["@Password"].Value = pass; command.Parameters["@Password"].Direction = ParameterDirection.Input; adapter = new SqlDataAdapter(command.CommandText, connection); adapter.Fill(ans); return ans; } catch (Exception ex) { throw ex; }
<add name="MainConnectionString" connectionString="Data Source=MIKLAT\SQLEXPRESS;Initial Catalog=...;Integrated Security=True; providerName="System.Data.SqlClient"/>