我很難將WONum插入到我的sql字符串中。 我曾嘗試在WONum周圍使用'和double''。有人還建議#和[],但目前沒有任何工作。在vb.net中插入字符串變量到sql字符串
我不斷收到以下錯誤:附近有語法錯誤「1577」
WONum值實際上WO-1577是在運行時間,但執行DA.fill當我得到這個錯誤。我開始認爲破折號在sql中做了一些我不知道的事情。任何幫助都會有所幫助,因爲我必須在我的應用程序中執行更多類似的功能。
Public Function GetTechTimes(ByVal WONum As String)
Dim strSQL As String = "Select customer_name, workorder_work_to_be_performed, workorder_work_performed, workorder_notes, workorder_warranty_work, workorder_open_date, workorder_status,workorder_completion_date, wo_tech_name, wo_tech_time, wo_parts_description from Customers, workorders, WorkOrder_Technicians, WorkOrder_Parts Where(customer_id = workorder_customer And wo_tech_wo_id = workorder_id And wo_parts_wo_id = workorder_id And workorder_number = " & WONum & ""
Dim DA As New SqlDataAdapter(strSQL, Conn)
Dim DS As New DataSet
DA.Fill(DS, "TechTimes")
Return DS
End Function
這是可能的'從客戶選擇 ..., 工作訂單, WorkOrder_Technicians, WorkOrder_Parts'? –
spajce