Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2011
    Messaggi
    17

    The ConnectionString property has not been initialized.

    ho qst codice:

    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();

    mi da l errore nel conn.open...

    qlk mi aiuta?
    grazie

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2011
    Messaggi
    17
    risolto


    string connectionString = null;

    SqlConnection conn = new SqlConnection();
    ConnectionStringSettings settings = WebConfigurationManager.ConnectionStrings["CnnStr"];

    if (settings != null)
    {
    connectionString = settings.ConnectionString;
    }


    DataTable dTable = new DataTable();

    SqlCommand cmd = new SqlCommand();




    SqlHelper helper = new SqlHelper(connectionString);

    cmd.CommandType = CommandType.Text;
    cmd.CommandText = "SELECT UserName,Password FROM AnagraficaUtenti WHERE UserName='qwerty' and Password='qwerty'";
    dTable = helper.SelectQuery(cmd);

    if (dTable != null)
    {
    if (dTable.Rows.Count > 0)
    {
    //Response.Redirect("loginOk.aspx");
    Server.Transfer("loginOk.aspx");
    }
    else
    {

    }
    }

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.