0
我coppied一些代碼HERE但我得到一個錯誤:「不正確的語法附近‘)’ 但我看不出什麼毛病此代碼DataAdaptor.Fill錯誤
Dim conString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\users.mdf;Integrated Security=True;User Instance=True"
Dim con As New SqlConnection(conString)
con.Open()
Try
Dim dataAdapter1 As New SqlDataAdapter(_
New SqlCommand("SELECT subject, info, username, status FROM(problems) WHERE (username =" & userName & ")", con))
Dim ds As New DataSet("DataSetMyProbs")
ds.Tables.Add("UserProbs")
dataAdapter1.Fill(ds.Tables("UserProbs")) '//This is where i get the error'
Me.bsMyProblems.DataSource = ds.Tables("UserProbs")
Dim dataAdapter2 As New SqlDataAdapter(_
New SqlCommand("SELECT dep, pcid, username, status, extraInfo FROM(deployments) WHERE (username = " & userName & ")", con))
ds.Tables.Add("UsersDepl")
dataAdapter2.Fill(ds.Tables("UserDepl"))
Me.bsMyDepl.DataSource = ds.Tables("UserDepl")
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
con.Dispose()
End Try
感謝,只有一件事... 我不是現在得到的錯誤,但我加載了錯誤的查詢,我真的不明白這一點。我討厭SQL,mysql更容易 –
??你能幫助我嗎?爲什麼它總是加載1個特定用戶,即使我在查詢中發送其他用戶。這可能是綁定導航器還是其他東西 –
當您在查詢中發送其他用戶時,您是否使用IN?或者只是用不同的參數再次調用函數? – Nick