Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 14th, 2006, 03:31 PM
Authorized User
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataSet problem

Hi

I seem to be getting an error when trying to run the below code: -

     Function CustomersEdit() As System.Data.DataSet
       Dim connectionString As String = _
              ConfigurationSettings.AppSettings("ConnectionStrin g")
       Dim dbConnection As System.Data.IDbConnection = _
              New System.Data.OleDb.OleDbConnection(connectionString )

       Dim queryString As String = "SELECT [Customers].[CustomerName], [Customers].[Address1], [Customers].[SiteLogin],"& _
     "[Customers].[SitePassword], [Customers].[CustomerID] FROM [Customers]"
       Dim dbCommand As System.Data.IDbCommand = _
              New System.Data.OleDb.OleDbCommand
       dbCommand.CommandText = queryString
       dbCommand.Connection = dbConnection

       Dim dataAdapter As System.Data.IDbDataAdapter = _
              New System.Data.OleDb.OleDbDataAdapter
       dataAdapter.SelectCommand = dbCommand
       Dim dataSet As System.Data.DataSet = New System.Data.DataSet
       dataAdapter.Fill(dataSet)


       Return dataSet
     End Function

The line that displays the error is the one in bold, of which it is advising "The ConnectionString property has not been initialized."

Can anyone offer any suggestions?

Thanks
Sharon
 
Old November 14th, 2006, 04:58 PM
Authorized User
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have also set up the key for my web.config called ConnectionString so this can't be the problem.

Thanks

Sharon
 
Old November 15th, 2006, 02:16 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

HelpWanted:
According to the error message, the objAdapter is not finding the database referenced in your web.config. It is the Fill() method of the Adapter object that creates and/or populates the DataTable in the objDataSet. As you stated in your topic you have the web.config "ConnectionString" setup correctly, then make sure your web.config is in the correct place, like the web root directory.

As a suggestion: 1) use the import namespace directive. In your case
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.Oledb" %> Cuts down on the typing in your statements.

Hope this helps.
 
Old November 15th, 2006, 02:28 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

HelpWanted:
This same error has been addressed in the following topic:

http://p2p.wrox.com/topic.asp?TOPIC_ID=27910

Hope this helps.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset Problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 September 26th, 2006 10:04 AM
DataSet Example Problem sfx BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 February 14th, 2006 01:16 AM
problem in updating in dataset vohra_vikas2004 ADO.NET 1 June 28th, 2005 05:26 AM
Problem with Dataset Update Aaron Edwards ADO.NET 1 April 29th, 2005 04:26 AM
DataSet.WriteXML Problem jim.stanley ADO.NET 0 September 21st, 2004 12:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.