PC Review


Reply
Thread Tools Rate Thread

ConnnectionString Problem

 
 
Roshawn
Guest
Posts: n/a
 
      28th Jan 2004
Hi,

I have a Windows application that makes use of a config file. The config
file contains my connection string to an Access database. In my code-behind
file I've created a variable (ocon) that retrieves this data from the config
file using ConfigurationSettings.AppSettings.

From the code-behind file I call a method from an external .dll file that
accepts a valid connection string. I supply my variable (ocon) to the
method. However, when the code is run, I'm told that the ConnectionString
property of my connection object is not initialized. Here's my code:

Public Class Form1

'Windows Forms Designer Generated Code

Dim ocon as String = ConfigurationSettings.AppSettings("constr")
Private AG AS DataSet

Private Sub Form1_Load()
Dim adt as New AllData()
AG = adt.GetData(ocon)
End Sub

..................................

Namespace MAC
Public Class AllData
Dim ds as New DataSet()
Dim conn as OleDbConnection

Public Function GetData(ByVal constr As String) As DataSet
conn = New OleDbConnection(constr)
conn.Open()
'a few helper functions are placed here
conn.Close()
End Function
End Class

I've run the app dozens of times and the same error persists. Is there
something that I'm doing wrong? Is it possible to read from the config file
and pass the desired data to an external .dll file?

Thanks,
Roshawn


 
Reply With Quote
 
 
 
 
Roshawn
Guest
Posts: n/a
 
      28th Jan 2004
Yes I did. It is set like this:
<configuration>
<appSettings>
<add key="constr" value="Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=E:\AGG.mdb" />
</appSettings>
</configuration>

For some strange reason or another, it doesn't work.
"Tu-Thach" <(E-Mail Removed)> wrote in message
news:67B04A00-BB19-46A5-8502-(E-Mail Removed)...
> Roshawn,
> Did you check your config file and make sure that the "constr" key set?
>
> Tu-Thach
>
> ----- Roshawn wrote: -----
>
> Hi,
>
> I have a Windows application that makes use of a config file. The

config
> file contains my connection string to an Access database. In my

code-behind
> file I've created a variable (ocon) that retrieves this data from the

config
> file using ConfigurationSettings.AppSettings.
>
> From the code-behind file I call a method from an external .dll file

that
> accepts a valid connection string. I supply my variable (ocon) to

the
> method. However, when the code is run, I'm told that the

ConnectionString
> property of my connection object is not initialized. Here's my code:
>
> Public Class Form1
>
> 'Windows Forms Designer Generated Code
>
> Dim ocon as String = ConfigurationSettings.AppSettings("constr")
> Private AG AS DataSet
>
> Private Sub Form1_Load()
> Dim adt as New AllData()
> AG = adt.GetData(ocon)
> End Sub
>
> ..................................
>
> Namespace MAC
> Public Class AllData
> Dim ds as New DataSet()
> Dim conn as OleDbConnection
>
> Public Function GetData(ByVal constr As String) As DataSet
> conn = New OleDbConnection(constr)
> conn.Open()
> 'a few helper functions are placed here
> conn.Close()
> End Function
> End Class
>
> I've run the app dozens of times and the same error persists. Is

there
> something that I'm doing wrong? Is it possible to read from the

config file
> and pass the desired data to an external .dll file?
>
> Thanks,
> Roshawn
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem after problem after problem - winXP wont start! =?Utf-8?B?TWF2aXJpY2s=?= Windows XP Help 2 23rd Apr 2006 02:55 PM
System Restore Tab still has access problem (multi-disk problem?) srrstr.dll error Dallas Overturf Windows XP Performance 0 12th Mar 2006 12:52 PM
Microsoft Access Object Library Version Problem (Form VBA Code Problem) Don Microsoft Access Form Coding 2 8th Mar 2004 01:00 PM
hibernation problem! problem!, Power Option problem! Farzad Hayati Microsoft Windows 2000 Hardware 2 5th Feb 2004 10:22 PM
hibernation problem! problem!, Power Option problem! Farzad Hayati Microsoft Windows 2000 Advanced Server 2 5th Feb 2004 10:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:50 AM.