我知道这是一个重复的帖子,但我无法找到有关该主题的解决方案。我想在调试文件夹中连接我的sql文件但是我收到了用户''登录失败的错误。
<p>
你能告诉我我的错误吗?
答案 0 :(得分:0)
Dim ds As New DataSet()
Using connection As New SqlConnection(String.Format("Data Source=.\SQLEXPRESS;AttachDbFilename={0}\Word.mdf;Integrated Security=true;Connect Timeout=30;User Instance=True", My.Application.Info.DirectoryPath))
connection.Open()
Using command As New SqlCommand("SELECT * FROM test", connection)
command.CommandTimeout = 0
Using da As New SqlDataAdapter(command)
da.Fill(ds)
End Using
End Using
End Using
DataGridView1.DataSource = ds
MakePivot()
DataGridView2.ClearSelection()
试用此代码,需要设置“integrated security = true”