ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property h

Discussion in 'ASP .Net' started by Tony, Jun 15, 2004.

  1. Tony

    Tony Guest

    Dear All,
    When I run an example program on the
    http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3

    I received an error message:



    "The ConnectionString property has not been initialized.

    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The ConnectionString
    property has not been initialized.

    Source Error:

    Line 11: Line 12: DataSet ds = new DataSet();Line 13:
    myCommand.Fill(ds, "Authors");Line 14: Line 15:
    MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you tell me
    what's wrong? Thanks!
    The example code is below:
    ======================

    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <html>
    <script language="VB" runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
    Dim DS As DataSet
    Dim MyConnection As SqlConnection
    Dim MyCommand As SqlDataAdapter
    MyConnection = New
    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    ring"))
    MyCommand = New SqlDataAdapter("select * from Authors",
    MyConnection)
    DS = new DataSet()
    MyCommand.Fill(ds, "Authors")
    MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
    MyDataGrid.DataBind()
    End Sub
    </script>
    <body>
    <h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3>
    <ASP:DataGrid id="MyDataGrid" runat="server"
    Width="700"
    BackColor="#ccccff"
    BorderColor="black"
    ShowFooter="false"
    CellPadding=3
    CellSpacing="0"
    Font-Name="Verdana"
    Font-Size="8pt"
    HeaderStyle-BackColor="#aaaadd"
    EnableViewState="false"
    />
    </body>
    </html>
     
    Tony, Jun 15, 2004
    #1
    1. Advertising

  2. do you have a web.config file with these lines

    <appSettings>
    <add key="PubsString" key="your connectionstring here" />
    </appSettings>

    Regards
    Martin


    "Tony" <> wrote in message
    news:...
    > Dear All,
    > When I run an example program on the
    >

    http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3
    >
    > I received an error message:
    >
    >
    >
    > "The ConnectionString property has not been initialized.
    >
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.InvalidOperationException: The ConnectionString
    > property has not been initialized.
    >
    > Source Error:
    >
    > Line 11: Line 12: DataSet ds = new DataSet();Line 13:
    > myCommand.Fill(ds, "Authors");Line 14: Line 15:
    > MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you tell me
    > what's wrong? Thanks!
    > The example code is below:
    > ======================
    >
    > <%@ Import Namespace="System.Data" %>
    > <%@ Import Namespace="System.Data.SqlClient" %>
    > <html>
    > <script language="VB" runat="server">
    > Sub Page_Load(Sender As Object, E As EventArgs)
    > Dim DS As DataSet
    > Dim MyConnection As SqlConnection
    > Dim MyCommand As SqlDataAdapter
    > MyConnection = New
    >

    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    > ring"))
    > MyCommand = New SqlDataAdapter("select * from Authors",
    > MyConnection)
    > DS = new DataSet()
    > MyCommand.Fill(ds, "Authors")
    > MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
    > MyDataGrid.DataBind()
    > End Sub
    > </script>
    > <body>
    > <h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3>
    > <ASP:DataGrid id="MyDataGrid" runat="server"
    > Width="700"
    > BackColor="#ccccff"
    > BorderColor="black"
    > ShowFooter="false"
    > CellPadding=3
    > CellSpacing="0"
    > Font-Name="Verdana"
    > Font-Size="8pt"
    > HeaderStyle-BackColor="#aaaadd"
    > EnableViewState="false"
    > />
    > </body>
    > </html>
    >
    >
     
    Martin Marinov, Jun 15, 2004
    #2
    1. Advertising

  3. Tony

    Tony Guest

    Thank you for your help.

    There is no such paragragh in the web.config file. Which place i can add
    these lines into this file?

    "Martin Marinov" <> wrote in message
    news:%...
    > do you have a web.config file with these lines
    >
    > <appSettings>
    > <add key="PubsString" key="your connectionstring here" />
    > </appSettings>
    >
    > Regards
    > Martin
    >
    >
    > "Tony" <> wrote in message
    > news:...
    > > Dear All,
    > > When I run an example program on the
    > >

    >

    http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3
    > >
    > > I received an error message:
    > >
    > >
    > >
    > > "The ConnectionString property has not been initialized.
    > >
    > > Description: An unhandled exception occurred during the execution of the
    > > current web request. Please review the stack trace for more information
    > > about the error and where it originated in the code.
    > >
    > > Exception Details: System.InvalidOperationException: The

    ConnectionString
    > > property has not been initialized.
    > >
    > > Source Error:
    > >
    > > Line 11: Line 12: DataSet ds = new DataSet();Line 13:
    > > myCommand.Fill(ds, "Authors");Line 14: Line 15:
    > > MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you tell me
    > > what's wrong? Thanks!
    > > The example code is below:
    > > ======================
    > >
    > > <%@ Import Namespace="System.Data" %>
    > > <%@ Import Namespace="System.Data.SqlClient" %>
    > > <html>
    > > <script language="VB" runat="server">
    > > Sub Page_Load(Sender As Object, E As EventArgs)
    > > Dim DS As DataSet
    > > Dim MyConnection As SqlConnection
    > > Dim MyCommand As SqlDataAdapter
    > > MyConnection = New
    > >

    >

    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    > > ring"))
    > > MyCommand = New SqlDataAdapter("select * from Authors",
    > > MyConnection)
    > > DS = new DataSet()
    > > MyCommand.Fill(ds, "Authors")
    > > MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
    > > MyDataGrid.DataBind()
    > > End Sub
    > > </script>
    > > <body>
    > > <h3><font face="Verdana">Simple Select to a DataGrid

    Control</font></h3>
    > > <ASP:DataGrid id="MyDataGrid" runat="server"
    > > Width="700"
    > > BackColor="#ccccff"
    > > BorderColor="black"
    > > ShowFooter="false"
    > > CellPadding=3
    > > CellSpacing="0"
    > > Font-Name="Verdana"
    > > Font-Size="8pt"
    > > HeaderStyle-BackColor="#aaaadd"
    > > EnableViewState="false"
    > > />
    > > </body>
    > > </html>
    > >
    > >

    >
    >
     
    Tony, Jun 15, 2004
    #3
  4. your web.config must have such structure

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

    <system.web>

    .....

    </system.web>

    <appSettings>

    <add key="PubsString" key="your connectionstring here" />

    </appSettings>

    </configuration>

    Regards
    Martin


    "Tony" <> wrote in message
    news:u0g$...
    >
    >
    > Thank you for your help.
    >
    > There is no such paragragh in the web.config file. Which place i can add
    > these lines into this file?
    >
    > "Martin Marinov" <> wrote in message
    > news:%...
    > > do you have a web.config file with these lines
    > >
    > > <appSettings>
    > > <add key="PubsString" key="your connectionstring here" />
    > > </appSettings>
    > >
    > > Regards
    > > Martin
    > >
    > >
    > > "Tony" <> wrote in message
    > > news:...
    > > > Dear All,
    > > > When I run an example program on the
    > > >

    > >

    >

    http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3
    > > >
    > > > I received an error message:
    > > >
    > > >
    > > >
    > > > "The ConnectionString property has not been initialized.
    > > >
    > > > Description: An unhandled exception occurred during the execution of

    the
    > > > current web request. Please review the stack trace for more

    information
    > > > about the error and where it originated in the code.
    > > >
    > > > Exception Details: System.InvalidOperationException: The

    > ConnectionString
    > > > property has not been initialized.
    > > >
    > > > Source Error:
    > > >
    > > > Line 11: Line 12: DataSet ds = new DataSet();Line 13:
    > > > myCommand.Fill(ds, "Authors");Line 14: Line 15:
    > > > MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you tell

    me
    > > > what's wrong? Thanks!
    > > > The example code is below:
    > > > ======================
    > > >
    > > > <%@ Import Namespace="System.Data" %>
    > > > <%@ Import Namespace="System.Data.SqlClient" %>
    > > > <html>
    > > > <script language="VB" runat="server">
    > > > Sub Page_Load(Sender As Object, E As EventArgs)
    > > > Dim DS As DataSet
    > > > Dim MyConnection As SqlConnection
    > > > Dim MyCommand As SqlDataAdapter
    > > > MyConnection = New
    > > >

    > >

    >

    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    > > > ring"))
    > > > MyCommand = New SqlDataAdapter("select * from Authors",
    > > > MyConnection)
    > > > DS = new DataSet()
    > > > MyCommand.Fill(ds, "Authors")
    > > > MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
    > > > MyDataGrid.DataBind()
    > > > End Sub
    > > > </script>
    > > > <body>
    > > > <h3><font face="Verdana">Simple Select to a DataGrid

    > Control</font></h3>
    > > > <ASP:DataGrid id="MyDataGrid" runat="server"
    > > > Width="700"
    > > > BackColor="#ccccff"
    > > > BorderColor="black"
    > > > ShowFooter="false"
    > > > CellPadding=3
    > > > CellSpacing="0"
    > > > Font-Name="Verdana"
    > > > Font-Size="8pt"
    > > > HeaderStyle-BackColor="#aaaadd"
    > > > EnableViewState="false"
    > > > />
    > > > </body>
    > > > </html>
    > > >
    > > >

    > >
    > >

    >
    >
     
    Martin Marinov, Jun 15, 2004
    #4
  5. Tony

    Tony Guest

    Dear Martin,

    Thak you for your quick reply.I am sorry for interrupt you again,

    I have added the following lines into the web.config file,

    <appSettings>
    <add key="PubsString" value="Provider='sqloledb';Initial Catalog='Pubs';
    uid='v-tleung';pwd='Mynameis@01'">
    </add>
    </appSettings>

    but i recieved the following error:

    "Exception Details: System.ArgumentException: Keyword not supported:
    'provider'.

    Source Error:
    Line 11: Dim MyCommand As SqlDataAdapter
    Line 12:
    Line 13: MyConnection = New
    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    ring"))
    Line 14: MyCommand = New SqlDataAdapter("select * from Authors",
    MyConnection)
    Line 15:

    I have installed Sql Server on my localhost. How can we compose the
    ConnectionString. Does this program work well on your side?

    "Martin Marinov" <> wrote in message
    news:...
    >
    > your web.config must have such structure
    >
    > <?xml version="1.0" encoding="utf-8" ?>
    >
    > <configuration>
    >
    > <system.web>
    >
    > ....
    >
    > </system.web>
    >
    > <appSettings>
    >
    > <add key="PubsString" key="your connectionstring here" />
    >
    > </appSettings>
    >
    > </configuration>
    >
    > Regards
    > Martin
    >
    >
    > "Tony" <> wrote in message
    > news:u0g$...
    > >
    > >
    > > Thank you for your help.
    > >
    > > There is no such paragragh in the web.config file. Which place i can add
    > > these lines into this file?
    > >
    > > "Martin Marinov" <> wrote in message
    > > news:%...
    > > > do you have a web.config file with these lines
    > > >
    > > > <appSettings>
    > > > <add key="PubsString" key="your connectionstring here" />
    > > > </appSettings>
    > > >
    > > > Regards
    > > > Martin
    > > >
    > > >
    > > > "Tony" <> wrote in message
    > > > news:...
    > > > > Dear All,
    > > > > When I run an example program on the
    > > > >
    > > >

    > >

    >

    http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3
    > > > >
    > > > > I received an error message:
    > > > >
    > > > >
    > > > >
    > > > > "The ConnectionString property has not been initialized.
    > > > >
    > > > > Description: An unhandled exception occurred during the execution of

    > the
    > > > > current web request. Please review the stack trace for more

    > information
    > > > > about the error and where it originated in the code.
    > > > >
    > > > > Exception Details: System.InvalidOperationException: The

    > > ConnectionString
    > > > > property has not been initialized.
    > > > >
    > > > > Source Error:
    > > > >
    > > > > Line 11: Line 12: DataSet ds = new DataSet();Line 13:
    > > > > myCommand.Fill(ds, "Authors");Line 14: Line 15:
    > > > > MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you tell

    > me
    > > > > what's wrong? Thanks!
    > > > > The example code is below:
    > > > > ======================
    > > > >
    > > > > <%@ Import Namespace="System.Data" %>
    > > > > <%@ Import Namespace="System.Data.SqlClient" %>
    > > > > <html>
    > > > > <script language="VB" runat="server">
    > > > > Sub Page_Load(Sender As Object, E As EventArgs)
    > > > > Dim DS As DataSet
    > > > > Dim MyConnection As SqlConnection
    > > > > Dim MyCommand As SqlDataAdapter
    > > > > MyConnection = New
    > > > >
    > > >

    > >

    >

    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    > > > > ring"))
    > > > > MyCommand = New SqlDataAdapter("select * from Authors",
    > > > > MyConnection)
    > > > > DS = new DataSet()
    > > > > MyCommand.Fill(ds, "Authors")
    > > > > MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
    > > > > MyDataGrid.DataBind()
    > > > > End Sub
    > > > > </script>
    > > > > <body>
    > > > > <h3><font face="Verdana">Simple Select to a DataGrid

    > > Control</font></h3>
    > > > > <ASP:DataGrid id="MyDataGrid" runat="server"
    > > > > Width="700"
    > > > > BackColor="#ccccff"
    > > > > BorderColor="black"
    > > > > ShowFooter="false"
    > > > > CellPadding=3
    > > > > CellSpacing="0"
    > > > > Font-Name="Verdana"
    > > > > Font-Size="8pt"
    > > > > HeaderStyle-BackColor="#aaaadd"
    > > > > EnableViewState="false"
    > > > > />
    > > > > </body>
    > > > > </html>
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Tony, Jun 15, 2004
    #5
  6. Well, because of using sql client you can not use the oledb provider
    try using this connection string :

    workstation id=your_computer_name;packet size=4096;user id=v-tleung;data
    source=your_sql_server;persist security info=False;initial catalog=Pubs;
    Password=Mynameis@01;

    if your sql server is installed locally for data source put : localhost

    you can see here all of possible connection strings :
    http://www.connectionstrings.com/

    Regards
    Martin

    "Tony" <> wrote in message
    news:uLZ$...
    > Dear Martin,
    >
    > Thak you for your quick reply.I am sorry for interrupt you again,
    >
    > I have added the following lines into the web.config file,
    >
    > <appSettings>
    > <add key="PubsString" value="Provider='sqloledb';Initial Catalog='Pubs';
    > uid='v-tleung';pwd='Mynameis@01'">
    > </add>
    > </appSettings>
    >
    > but i recieved the following error:
    >
    > "Exception Details: System.ArgumentException: Keyword not supported:
    > 'provider'.
    >
    > Source Error:
    > Line 11: Dim MyCommand As SqlDataAdapter
    > Line 12:
    > Line 13: MyConnection = New
    >

    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    > ring"))
    > Line 14: MyCommand = New SqlDataAdapter("select * from Authors",
    > MyConnection)
    > Line 15:
    >
    > I have installed Sql Server on my localhost. How can we compose the
    > ConnectionString. Does this program work well on your side?
    >
    > "Martin Marinov" <> wrote in message
    > news:...
    > >
    > > your web.config must have such structure
    > >
    > > <?xml version="1.0" encoding="utf-8" ?>
    > >
    > > <configuration>
    > >
    > > <system.web>
    > >
    > > ....
    > >
    > > </system.web>
    > >
    > > <appSettings>
    > >
    > > <add key="PubsString" key="your connectionstring here" />
    > >
    > > </appSettings>
    > >
    > > </configuration>
    > >
    > > Regards
    > > Martin
    > >
    > >
    > > "Tony" <> wrote in message
    > > news:u0g$...
    > > >
    > > >
    > > > Thank you for your help.
    > > >
    > > > There is no such paragragh in the web.config file. Which place i can

    add
    > > > these lines into this file?
    > > >
    > > > "Martin Marinov" <> wrote in message
    > > > news:%...
    > > > > do you have a web.config file with these lines
    > > > >
    > > > > <appSettings>
    > > > > <add key="PubsString" key="your connectionstring here" />
    > > > > </appSettings>
    > > > >
    > > > > Regards
    > > > > Martin
    > > > >
    > > > >
    > > > > "Tony" <> wrote in message
    > > > > news:...
    > > > > > Dear All,
    > > > > > When I run an example program on the
    > > > > >
    > > > >
    > > >

    > >

    >

    http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3
    > > > > >
    > > > > > I received an error message:
    > > > > >
    > > > > >
    > > > > >
    > > > > > "The ConnectionString property has not been initialized.
    > > > > >
    > > > > > Description: An unhandled exception occurred during the execution

    of
    > > the
    > > > > > current web request. Please review the stack trace for more

    > > information
    > > > > > about the error and where it originated in the code.
    > > > > >
    > > > > > Exception Details: System.InvalidOperationException: The
    > > > ConnectionString
    > > > > > property has not been initialized.
    > > > > >
    > > > > > Source Error:
    > > > > >
    > > > > > Line 11: Line 12: DataSet ds = new DataSet();Line 13:
    > > > > > myCommand.Fill(ds, "Authors");Line 14: Line 15:
    > > > > > MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you

    tell
    > > me
    > > > > > what's wrong? Thanks!
    > > > > > The example code is below:
    > > > > > ======================
    > > > > >
    > > > > > <%@ Import Namespace="System.Data" %>
    > > > > > <%@ Import Namespace="System.Data.SqlClient" %>
    > > > > > <html>
    > > > > > <script language="VB" runat="server">
    > > > > > Sub Page_Load(Sender As Object, E As EventArgs)
    > > > > > Dim DS As DataSet
    > > > > > Dim MyConnection As SqlConnection
    > > > > > Dim MyCommand As SqlDataAdapter
    > > > > > MyConnection = New
    > > > > >
    > > > >
    > > >

    > >

    >

    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    > > > > > ring"))
    > > > > > MyCommand = New SqlDataAdapter("select * from Authors",
    > > > > > MyConnection)
    > > > > > DS = new DataSet()
    > > > > > MyCommand.Fill(ds, "Authors")
    > > > > > MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
    > > > > > MyDataGrid.DataBind()
    > > > > > End Sub
    > > > > > </script>
    > > > > > <body>
    > > > > > <h3><font face="Verdana">Simple Select to a DataGrid
    > > > Control</font></h3>
    > > > > > <ASP:DataGrid id="MyDataGrid" runat="server"
    > > > > > Width="700"
    > > > > > BackColor="#ccccff"
    > > > > > BorderColor="black"
    > > > > > ShowFooter="false"
    > > > > > CellPadding=3
    > > > > > CellSpacing="0"
    > > > > > Font-Name="Verdana"
    > > > > > Font-Size="8pt"
    > > > > > HeaderStyle-BackColor="#aaaadd"
    > > > > > EnableViewState="false"
    > > > > > />
    > > > > > </body>
    > > > > > </html>
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Martin Marinov, Jun 15, 2004
    #6
  7. Tony

    Tony Guest

    Dear Martin,



    It works!!



    After I used the following connection string:



    ¡°workstation id='sha-tongl-xp1';uid=sa;pwd='';server=localhost;initial
    catalog='Pubs'¡±



    I really appreciated your help. Have a wonderful day!



    "Martin Marinov" <> wrote in message
    news:%23NN$...
    > Well, because of using sql client you can not use the oledb provider
    > try using this connection string :
    >
    > workstation id=your_computer_name;packet size=4096;user id=v-tleung;data
    > source=your_sql_server;persist security info=False;initial catalog=Pubs;
    > Password=Mynameis@01;
    >
    > if your sql server is installed locally for data source put : localhost
    >
    > you can see here all of possible connection strings :
    > http://www.connectionstrings.com/
    >
    > Regards
    > Martin
    >
    > "Tony" <> wrote in message
    > news:uLZ$...
    > > Dear Martin,
    > >
    > > Thak you for your quick reply.I am sorry for interrupt you again,
    > >
    > > I have added the following lines into the web.config file,
    > >
    > > <appSettings>
    > > <add key="PubsString" value="Provider='sqloledb';Initial

    Catalog='Pubs';
    > > uid='v-tleung';pwd='Mynameis@01'">
    > > </add>
    > > </appSettings>
    > >
    > > but i recieved the following error:
    > >
    > > "Exception Details: System.ArgumentException: Keyword not supported:
    > > 'provider'.
    > >
    > > Source Error:
    > > Line 11: Dim MyCommand As SqlDataAdapter
    > > Line 12:
    > > Line 13: MyConnection = New
    > >

    >

    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    > > ring"))
    > > Line 14: MyCommand = New SqlDataAdapter("select * from Authors",
    > > MyConnection)
    > > Line 15:
    > >
    > > I have installed Sql Server on my localhost. How can we compose the
    > > ConnectionString. Does this program work well on your side?
    > >
    > > "Martin Marinov" <> wrote in message
    > > news:...
    > > >
    > > > your web.config must have such structure
    > > >
    > > > <?xml version="1.0" encoding="utf-8" ?>
    > > >
    > > > <configuration>
    > > >
    > > > <system.web>
    > > >
    > > > ....
    > > >
    > > > </system.web>
    > > >
    > > > <appSettings>
    > > >
    > > > <add key="PubsString" key="your connectionstring here" />
    > > >
    > > > </appSettings>
    > > >
    > > > </configuration>
    > > >
    > > > Regards
    > > > Martin
    > > >
    > > >
    > > > "Tony" <> wrote in message
    > > > news:u0g$...
    > > > >
    > > > >
    > > > > Thank you for your help.
    > > > >
    > > > > There is no such paragragh in the web.config file. Which place i can

    > add
    > > > > these lines into this file?
    > > > >
    > > > > "Martin Marinov" <> wrote in message
    > > > > news:%...
    > > > > > do you have a web.config file with these lines
    > > > > >
    > > > > > <appSettings>
    > > > > > <add key="PubsString" key="your connectionstring here" />
    > > > > > </appSettings>
    > > > > >
    > > > > > Regards
    > > > > > Martin
    > > > > >
    > > > > >
    > > > > > "Tony" <> wrote in message
    > > > > > news:...
    > > > > > > Dear All,
    > > > > > > When I run an example program on the
    > > > > > >
    > > > > >
    > > > >
    > > >

    > >

    >

    http://www.dotnetjunkies.com/quicks...a/datagrid1.src&file=VB\datagrid1.aspx&font=3
    > > > > > >
    > > > > > > I received an error message:
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > > "The ConnectionString property has not been initialized.
    > > > > > >
    > > > > > > Description: An unhandled exception occurred during the

    execution
    > of
    > > > the
    > > > > > > current web request. Please review the stack trace for more
    > > > information
    > > > > > > about the error and where it originated in the code.
    > > > > > >
    > > > > > > Exception Details: System.InvalidOperationException: The
    > > > > ConnectionString
    > > > > > > property has not been initialized.
    > > > > > >
    > > > > > > Source Error:
    > > > > > >
    > > > > > > Line 11: Line 12: DataSet ds = new DataSet();Line 13:
    > > > > > > myCommand.Fill(ds, "Authors");Line 14: Line 15:
    > > > > > > MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;"Can you

    > tell
    > > > me
    > > > > > > what's wrong? Thanks!
    > > > > > > The example code is below:
    > > > > > > ======================
    > > > > > >
    > > > > > > <%@ Import Namespace="System.Data" %>
    > > > > > > <%@ Import Namespace="System.Data.SqlClient" %>
    > > > > > > <html>
    > > > > > > <script language="VB" runat="server">
    > > > > > > Sub Page_Load(Sender As Object, E As EventArgs)
    > > > > > > Dim DS As DataSet
    > > > > > > Dim MyConnection As SqlConnection
    > > > > > > Dim MyCommand As SqlDataAdapter
    > > > > > > MyConnection = New
    > > > > > >
    > > > > >
    > > > >
    > > >

    > >

    >

    SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsSt
    > > > > > > ring"))
    > > > > > > MyCommand = New SqlDataAdapter("select * from Authors",
    > > > > > > MyConnection)
    > > > > > > DS = new DataSet()
    > > > > > > MyCommand.Fill(ds, "Authors")
    > > > > > > MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
    > > > > > > MyDataGrid.DataBind()
    > > > > > > End Sub
    > > > > > > </script>
    > > > > > > <body>
    > > > > > > <h3><font face="Verdana">Simple Select to a DataGrid
    > > > > Control</font></h3>
    > > > > > > <ASP:DataGrid id="MyDataGrid" runat="server"
    > > > > > > Width="700"
    > > > > > > BackColor="#ccccff"
    > > > > > > BorderColor="black"
    > > > > > > ShowFooter="false"
    > > > > > > CellPadding=3
    > > > > > > CellSpacing="0"
    > > > > > > Font-Name="Verdana"
    > > > > > > Font-Size="8pt"
    > > > > > > HeaderStyle-BackColor="#aaaadd"
    > > > > > > EnableViewState="false"
    > > > > > > />
    > > > > > > </body>
    > > > > > > </html>
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Tony, Jun 15, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Kennedy
    Replies:
    0
    Views:
    1,535
    Jeff Kennedy
    Oct 20, 2003
  2. Elmo Watson
    Replies:
    0
    Views:
    730
    Elmo Watson
    Jun 14, 2007
  3. Bill Nguyen
    Replies:
    4
    Views:
    449
    Paul Glavich [MVP ASP.NET]
    Feb 20, 2005
  4. Antoni Massó Mola
    Replies:
    1
    Views:
    414
    Michelle Hlaing
    Feb 24, 2005
  5. Eric
    Replies:
    1
    Views:
    221
Loading...

Share This Page