Hi tallbry
I am also an upcomming
vb .net superstar, Contrary to popular beleif it is possible to do as you wish, although many have said that keeping an open connection is a bad idea, however this is not as bad as it is made out to be, and can be less costly on the sql server than opening a connection each time you need to retrieve data.
so here is how to do it in
vb .net
create a
vb .net windows application
add a module to the application, adding the following code
Imports System.Data.SqlClient
Module Module1
Public Success As String
Public connection As SqlConnection
Sub main()
Dim Database As String = "[databasename]"
Dim ServerName As String = "[servername]"
Dim ConString As String = "Server=" & ServerName & ";Initial Catalog=" & Database & ";User ID=;Password="
Dim connection As New SqlConnection(ConString)
' connect to the db
Try
connection.Open()
Catch
'errormessage
Success = "sql connection failed"
End Try
Success = "sql connection successful"
Dim form1 As New Form1
form1.ShowDialog()
End Sub
End Module
of course changeing the sql connection requirements to suit your environment.
you will now be able to call these variables from any form within your application.
on form1 add the following code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox(Success)
End Sub
this will generate a message box that will tell you if the connection has failed or succeded.
from here all you need to do when you require data is call connection this connection will remain available untill you exit the application.