Results 1 to 8 of 8

Thread: My Connection String Is not working properly [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    56

    My Connection String Is not working properly [RESOLVED]

    Dear all;

    I am connecting my app to an mdb file...
    I need to accomplish the following:
    1- Connect to my acces file succefully
    2- Query the database and see the data.
    3- Compare it with the users password in order to grant or fail access to the website.

    Here is my code:
    Code:
            Dim DS As DataSet
              Dim MyConnection As SqlConnection
              Dim MyCommand As SqlDataAdapter
    
              MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\DBs\db1.mdb"))
              MyCommand = New SqlDataAdapter("select * from Students", myConnection)
    
              DS = new DataSet()
              MyCommand.Fill(DS, "Students")
    
              datagrid1.DataSource = DS.Tables("Students").DefaultView
              datagrid1.DataBind()
         end sub

    When I run it, the following error comes:


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

    Source Error:


    Line 20:
    Line 21: DS = new DataSet()
    Line 22: MyCommand.Fill(DS, "Students")
    Line 23:
    Line 24: datagrid1.DataSource = DS.Tables("Students").DefaultView


    Source File: C:\Documents and Settings\Administrator\My Documents\STS\index.aspx Line: 22

    Stack Trace:


    [InvalidOperationException: The ConnectionString property has not been initialized.]
    System.Data.SqlClient.SqlConnection.Open() +809
    System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
    System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +98
    System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
    System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +36
    ASP.index_aspx.Page_Load(Object Sender, EventArgs E) in C:\Documents and Settings\Administrator\My Documents\STS\index.aspx:22
    System.Web.UI.Control.OnLoad(EventArgs e) +55
    System.Web.UI.Control.LoadRecursive() +21
    System.Web.UI.Page.ProcessRequestMain() +724






    Please advice, i have never made a connection to a database through ASP.Net before

    Regards
    Ahmed Abughoush
    Last edited by ahmedabugh; May 3rd, 2005 at 02:05 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width