An exert from my config file looks liek this.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="loglocal" value="C:\here.txt" />
<add key="ConnString" value="Data Source=DBNAME;InitialCatalog=CataName;Integrated Security=True"/>
<add key="UppBound" value="100" />
<add key="LowBound" value="100" />
</appSettings>
</configuration
I am attempting to pass in some values into my .net program, and the only one that works is the loglocal
which is picking a directory string.
I can pass in my bounds into queries but I cannot pass in the Connection string and open the connection.
I have tried passing in my own set of quotes as well before passing in the long query like:
Dim SQLCONN as new SqlConnection("""" & nameofconfvalue & """")
For reference my entire code looks like this.
Public Class Form1
Dim ConfUpperBound as Integer = Configuration.AppSettings("UppBound")
Dim ConfConnString as String = Configuration.AppSettings("ConnString")
Private Sub Button1_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
Dim SQLCONN as new SqlConnection("<either from config(fails) or hardcoded(works)>")
//fails on the below line (cannot open Connection)
SQLCONN.Open()
//I can successfully pass in values in query so I know i can connect to conf file
Dim SQLCMD as New SqlCommand("myquery etc etc")
SQLCMD.ExecuteNonQuery()
SQLCONN.Close()
End Sub
End Class
EDIT: I am able to pass in the string perfectly when using Visual Studio 2005. But when using VS 2003 and a loiwer .net framework it will not let me, unless I hard code it in.
Could something be enabled/disabled on one of these instances of VS? Or could this just be an error with the older versions of .net? I think I am using 1.1??(will have to check) in 2003.