problem with app.exe.config

W

wink martindale

Hello,
I am developing a vb.net application using a mySql database with
corelabs provider.
I am having a bit of difficulty getting a db connection to work. Here
is my app.exe.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appsettings>
<add key = "ConnectionString" value =
"Database=genesys;userid=daniel;password=*******;host=192.168.1.4;" />
</appsettings>


And here is the code:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim myCon As MySqlConnection
Dim myCmd As MySqlCommand
Dim strSql As String = ("Select * from pt_info")

myCon = New MySqlConnection
myCon.ConnectionString =
(System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"))
myCon.Open() <--error here
myCmd = New MySqlCommand(strSql, myCon)
Dim myReader As MySqlDataReader
myReader = myCmd.ExecuteReader()
If myReader.Read Then
Label1.Text = ("Successfull, baby")
End If
End Sub

For some reason, I am getting an ConnectionString property not
initialized error when the form loads. I can't figure out why
Can someone please help???

TIA,

Daniel
 
T

Terry Olsen

"Database=genesys;userid=daniel;password=*******;host=192.168.1.4;" />
myCon.ConnectionString =
(System.Configuration.ConfigurationSettings.AppSettings("ConnectionString"))
myCon.Open() <--error here

A few things to try...

change "userid" to "uid"
change "password" to "pwd"
change "host" to "server"
get rid of the trailing ";"

See if that makes a difference.

If that doesn't help, try this...

myCon.ConnectionString
="Database=genesys;userid=daniel;password=*******;host=192.168.1.4"

and see what happens...

here's a sample of what I use...
<appSettings>

<add key="TSG_CS"
value="server=mtgenwks0024;database=TSG_CS;UID=den1tro;PWD=*"/>

<add key="netop_phbook"
value="server=mtgenwks0024;database=netop_phbook;uid=den1tro;pwd=*"/>

</appSettings>
 
W

wink martindale

Thanks for the response. I will give those ideas a try! But, right
now, it is Friday night, and I must go have fun.
Will let you know Monday.
Thanks Again!

Daniel
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top