vb.net连接腾讯云 腾讯云vpc连接方式( 二 )


Dim str As String = "Data Source=服务器名;Initial Catalog=数据库名;Persist Security Info=True;User ID=;Password="
dim conn As SqlClient.SqlConnection
try
conn = New SqlClient.SqlConnection
conn.ConnectionString = str
conn.Open()
Return True
Catch ex As Exception
MsgBox(ex.ToString)
Return False
End Try
登录代码:Dim str As String = "Data Source=服务器名;Initial Catalog=数据库名;Persist Security Info=True;User ID=;Password="
dim conn As SqlClient.SqlConnection
conn = New SqlClient.SqlConnection
conn.ConnectionString = str
conn.Open()
sqlstr = "Select * From Amd Where AmdName='"TextBox1.Text"' And AmdPwd = '"TextBox2.Text"'"
Dim sqlcmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(sqlstr, conn)
Dim dr As SqlClient.SqlDataReader
dr = sqlcmd.ExecuteReader
If dr.Read = True Then'判断一条记录为真
kf.Show() '显示下个窗体
Me.Hide() ’隐藏当前窗体
Else
MessageBox.Show("输入信息有误!", "提示")
TextBox1.Text = ""
TextBox2.Text = ""
End If
使用vb.net如何访问服务器上的数据库用ADO接口就可以,TCP/IP协议 , 设定数据库服务器的IP地址 , 数据库名,用户名,密码就可以连接 。
vb.net连接腾讯云的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于腾讯云vpc连接方式、vb.net连接腾讯云的信息别忘了在本站进行查找喔 。

推荐阅读