ciao a tutti ho un problema urgente...
nella web.config ho:
<appSettings>
<add key="CnnStr" value="server=.\sqlexpress;uid=SA;pwd=BLACKBOX;dat abase=training"/>
</appSettings>
nel login.aspx.cs:
string connectionString = null;
SqlConnection conn = new SqlConnection();
ConnectionStringSettings settings = WebConfigurationManager.ConnectionStrings["CnnStr"];
if (settings != null)
{
connectionString = settings.ConnectionString;
}
conn.ConnectionString = connectionString;
DataTable getDataTable=new DataTable ();
DataTable ds = null;
SqlDataAdapter adapter = null;
SqlCommand cmd = null;
conn.Open();
string sSQL="SELECT UserName,Password FROM AnagraficaUtenti WHERE UserName='qwerty' and Password='qwerty'";
cmd = new SqlCommand(sSQL, conn);
cmd.CommandType = CommandType.Text;
adapter = new SqlDataAdapter(cmd);
ds = new DataTable();
adapter.Fill(ds);
adapter.Dispose();
la mia domanda e:ma sto leggendo la cnnstr dal web.config??e come faccio??
grazie

Rispondi quotando