Ontaining a connection string from app.config (1 Viewer)

CharlesWhiteman

Registered User.
Local time
Today, 13:42
Joined
Feb 26, 2007
Messages
421
Hi All,

I am using the following statements (with the correct namespace references declared) for the following which works fine.

I cannot work out how though to reference the connection string which is correctly referenced in my app.config file.

Any advice most welcome.

Code:
Private cs As New SqlConnection("Data Source=L004856\IRISPRACTICE;Initial Catalog=IRIS;Integrated Security=True")
Private da As New SqlDataAdapter("SELECT ClientName, ClientID, InternalID FROM iris.practice.ibvclient WHERE ClientID not like 'Z%'", cs)
Private ds As New DataSet
 

CharlesWhiteman

Registered User.
Local time
Today, 13:42
Joined
Feb 26, 2007
Messages
421
I am really stuck/googled out on trying to find out why my connection string wont initialise?

Code:
Imports System.Data.SqlClient
Imports System.Configuration
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.SqlConnection1.ConnectionString = _
System.Configuration.ConfigurationManager. _
AppSettings.Get("ConnectionString.IrisLookupString.")
Me.SqlConnection1.Open()
MsgBox(">> " & Me.SqlConnection1.State)
Dim ds As New DataSet
Dim da As New SqlDataAdapter("select * from Iris.Practice.IbvClient", _
SqlConnection1())
' da.Fill(ds, "Iris.Practice.IbvClient")
DG.DataSource = ds.Tables("iris.practice.ibvclient")
End Sub
End Class
 

Users who are viewing this thread

Top Bottom