我打算检查我的数据库是否连接到我在 vb.net 中的项目,但似乎我的代码或我的 SQL 服务器有问题。它总是向我显示一条消息“用户 'id/id2' 登录失败”。
这是我的代码:
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlconn As New SqlConnection
sqlconn.ConnectionString = "server = (local);Database=OJT;integrated security=true"
Try
sqlconn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Connection to Sql Server Failed!", MessageBoxButtons.OK)
End Try
Me.Text = "You are successfully connected to Sql Server"
End Sub
End Class