Hi,
Can anyone please give me some example code for linking to a ms sql database that is held on a web host's server.
The application that I am creating is a desktop app written in vb .net
The fields are simple, and are just stuff like customer name, address etc, and I just need to be able to connect to the database, pass some simple quereies (search by customer name etc).
Thanks!
Loading
GeoffPosted Jun 16, 2009, 11:09 AM
Module DataModule
Dim cnn As SqlConnection
Public Function Connect() As Boolean
Dim strConnectionString As String
Dim cnnOpen As Boolean
strConnectionString = "Data Source=ComputerName.DomainName.co.uk\SQLServerInstanceName;database=MyDatabaseName;Persist Security Info=True;User ID=SQLServerUserName;Password=UserPassword;Connect Timeout=30;User Instance=False"
Try
cnn = New SqlConnection(strConnectionString)
cnn.Open()
cnnOpen = True
Catch ex As Exception
cnnOpen = False
End Try
Return cnnOpen
End Function
End Module