Jump to content

Recommended Posts

Posted

Boa tarde a todos! Gostava de saber se por ventura alguém me poderia explicar como fazer uma ligação a base de dados que esteja num servidor. Será que alguém terá paciência para explicar como se eu fosse muito burro?

Desde já o meu muito obrigado.

Posted (edited)
Dim conn As New SqlClient.SqlConnection

Const connString As String = "Initial Catalog=nomebd;Data Source=nomeservidor\sqlexpress;Integrated Security=false;User Instance=false;User Id=aaaaaaaa;Password=bbbbbb"

Public Sub ConnectToSql()
Try
conn.ConnectionString = connString
conn.Open()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub

Public Sub DisconnectFromSql()
Try
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Edited by Caça
GeSHi

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.