Note that there are some explanatory texts on larger screens.

plurals
  1. POSolve the error "The ConnectionString property has not been initialized."?
    primarykey
    data
    text
    <p>My code is view all the data in the gridview</p> <p>Web.config code is</p> <pre><code>&lt;configuration&gt; &lt;connectionStrings&gt; &lt;add name="ConStr" connectionString="DataSource=.;Integrated Security=SSPI;Initial catalog=sshopping"/&gt; &lt;/connectionStrings&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.5"/&gt; &lt;httpRuntime targetFramework="4.5"/&gt; &lt;/system.web&gt; &lt;/configuration&gt; </code></pre> <p>It is coded in external class</p> <pre><code>namespace DBAction { public class ViewAction { public DataSet GetAllData() { SqlCommand cmd = DataConnection.GetConnection().CreateCommand(); cmd.CommandText = "Select UserName,Password,RoleName,EmailID,SecurityQuestion,SecurityAnswer,LastLogin from LoginInfo"; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); cmd.Dispose(); DataConnection.CloseConnection(); return ds; } } } </code></pre> <p>it is giving error in line <code>da.Fill(ds)</code> The code to bind data source with gridview is coded on page load like this.</p> <pre><code> DataSet ds = new ViewAction().GetAllData(); gvLoginInfo.DataSource = ds; gvLoginInfo.DataBind(); </code></pre> <p>And conectionstring code in data connection class is</p> <pre><code> public static SqlConnection GetConnection() { if (con == null) { con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString; con.Open(); } return con; } </code></pre> <p>And one one error is </p> <pre><code>Exception Details: System.ArgumentException: Keyword not supported: 'datasource'. Source Error: Line 19: { Line 20: con = new SqlConnection(); Line 21: con.ConnectionString =ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString; Line 22: con.Open(); Line 23: } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload