?
Solved

The ConnectionString property has not been initialized.

Posted on 2006-05-12
8
Medium Priority
?
476 Views
Last Modified: 2012-06-27
Hi guys,

This error occurs when I try to execute my application using an OleDbDataAdapter1

global.asax
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        Application("Connection") = ConfigurationSettings.AppSettings("ConnectionString")
End Sub

Web.config
<add key="ConnectionString" value="data source=W2K3-VS;initial catalog=Venus;password=Admin;user id=sa"/>

ClassComponent
Public Function QueryInfo(ByVal VoucherN As Int64) As DT_VDATOS1
        Dim item As New DT_VDATOS1
        OleDbDataAdapter1.SelectCommand.Parameters(0).Value = VoucherN
        item.Clear()
        OleDbDataAdapter1.Fill(item)  ******* I get the error here
        Return item
End Function

this is the oledbdataAdapter
SELECT VoucherNum, EMPRNO, SSNumber, DateRec
FROM OPENROWSET ('Microsoft.Jet.OLEDB.4.0' , 'C:\FlexPro DB.mdb' ; 'admin' ; '' , VOUCHERS) V WHERE (CONVERT (SMALLDATETIME, DateRec, 112) > '01-01-2006')
     AND (CONVERT (SMALLDATETIME, DateProcessed, 112) IS NULL)
     AND (VoucherNum = SUBSTRING(CAST(param1 AS VARCHAR(20)), 9, 6))

I have tried with sqlAdapter and I get the same error.

Anyone has an idea why I get this error.
Thanks
Carol
0
Comment
Question by:Carolinat
  • 4
  • 3
8 Comments
 

Author Comment

by:Carolinat
ID: 16667457
By the way I'm using visual studio 2003 and a sql server 2000
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16667479
Wheres the code that creates the connection object and ties it to the DataAdapter ?

Basically the error means that the connection object assigned to the DataAdapter hasn't had its ConnectionString set, so when Fill is called and it tries to open the connection it fails.
0
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16667492
and the oledbconnection have the connection string setted?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Carolinat
ID: 16667503
This is the code

queryvoucher is the class component

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        If Not IsPostBack Then
            Dim DtVouchers As New DT_VDATOS1
            Dim vQueryVoucher As QueryVoucher = New QueryVoucher
            vQueryVoucher.Connection = Application("ConnectionString")
            DtVouchers = vQueryVoucher.QueryInfo("87878787075380")
        End If
    End Sub
0
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16667504
Public Function QueryInfo(ByVal VoucherN As Int64) As DT_VDATOS1
        'Try adding this line and chage the name for yourConnection object
        yourOleDbConnection.connectionstring = Application("Connection")

        Dim item As New DT_VDATOS1
        OleDbDataAdapter1.SelectCommand.Parameters(0).Value = VoucherN
        item.Clear()
        OleDbDataAdapter1.Fill(item)  ******* I get the error here
        Return item
End Function
0
 

Author Comment

by:Carolinat
ID: 16667548
       OleDbConnection1.ConnectionString = Application("Connection")

It shows an error in Application: Name application is not declared
0
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 2000 total points
ID: 16667577
OleDbConnection1.ConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
0
 

Author Comment

by:Carolinat
ID: 16667600
excellent!!!!
Thank you very much!!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question