Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Private os_cnn As SqlClient.SqlConnection
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strConn As String
Try
strConn = "Persist Security Info=False;database=Txtest;server=192.168.1.10;user id=sa;Password="
os_cnn = New SqlClient.SqlConnection
os_cnn.ConnectionString = strConn
os_cnn.Open()
MsgBox("连接成功!")
Catch sqlex As SqlClient.SqlException
MsgBox("SQL" & sqlex.Message)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class