最近在用VB2008,每次运行之后都会提示System.Data.SqlClient.SqlException‘=’附近有语法错误,求教啊
我想删除生产调度(毕设)里的一些信息,先附上EditData.vb类内容:ImportsSystem.Data.SqlClientPublicClassEditDataS...
我想删除 生产调度(毕设)里的一些信息,先附上EditData.vb类内容:
Imports System.Data.SqlClient
Public Class EditData
Shared Function Insert(ByVal ConnStr As String, ByVal strSQL As String) As Integer
Dim conn As SqlConnection = New SqlConnection(ConnStr)
Dim myCommand As SqlCommand = New SqlCommand(strSQL, conn)
Dim count As Integer = 0
Try
conn.Open()
count = myCommand.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString())
Finally
conn.Close()
End Try
Return count
End Function
Shared Function Delete(ByVal ConnStr As String, ByVal table As String, ByVal row As String, ByVal value As String) As Integer
Dim conn As SqlConnection = New SqlConnection(ConnStr)
Dim strSQL As String = "DELETE FROM" + table + "WHERE" + row + "=" + "" + value + ""
Dim myCommand As SqlCommand = New SqlCommand(strSQL, conn)
Dim count As Integer = 0
Try
conn.Open()
count = myCommand.ExecuteNonQuery()
Catch ex As SqlException
MsgBox(ex.ToString())
Finally
conn.Close()
End Try
Return count
End Function
Shared Function Update(ByVal ConnStr As String, ByVal table As String, ByVal strContent As String, ByVal row As String, ByVal value As String) As Integer
Dim conn As SqlConnection = New SqlConnection(ConnStr)
Dim strSQL As String = "UPDATE" + table + "SET" + strContent + "WHERE" + row + "=" + "" + value + ""
Dim myCommand As SqlCommand = New SqlCommand(strSQL, conn)
Dim count As Integer = 0
Try
conn.Open()
count = myCommand.ExecuteNonQuery()
Catch ex As SqlException
MsgBox(ex.ToString())
Finally
conn.Close()
End Try
Return count
End Function
Shared Function Search(ByVal ConnStr As String, ByVal strSQL As String) As DataTable
'创建SqlConnection实例
Dim conn As SqlConnection = New SqlConnection(ConnStr)
'创建SQL命令
Dim myCommand As SqlCommand = New SqlCommand(strSQL, conn)
'打开数据库连接
conn.Open()
'设置适配器
Dim adapter As New SqlDataAdapter
adapter.TableMappings.Add("Table", "TEMP")
adapter.SelectCommand = myCommand
'填充数据集
Dim ObjectdsDataSet As New DataSet()
adapter.Fill(ObjectdsDataSet)
'关闭数据库连接
conn.Close()
'返回查询的表
Return ObjectdsDataSet.Tables("TEMP")
End Function
求教啊,但为修改这个错误就忙了一个星期了,请高手帮忙啊 展开
Imports System.Data.SqlClient
Public Class EditData
Shared Function Insert(ByVal ConnStr As String, ByVal strSQL As String) As Integer
Dim conn As SqlConnection = New SqlConnection(ConnStr)
Dim myCommand As SqlCommand = New SqlCommand(strSQL, conn)
Dim count As Integer = 0
Try
conn.Open()
count = myCommand.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString())
Finally
conn.Close()
End Try
Return count
End Function
Shared Function Delete(ByVal ConnStr As String, ByVal table As String, ByVal row As String, ByVal value As String) As Integer
Dim conn As SqlConnection = New SqlConnection(ConnStr)
Dim strSQL As String = "DELETE FROM" + table + "WHERE" + row + "=" + "" + value + ""
Dim myCommand As SqlCommand = New SqlCommand(strSQL, conn)
Dim count As Integer = 0
Try
conn.Open()
count = myCommand.ExecuteNonQuery()
Catch ex As SqlException
MsgBox(ex.ToString())
Finally
conn.Close()
End Try
Return count
End Function
Shared Function Update(ByVal ConnStr As String, ByVal table As String, ByVal strContent As String, ByVal row As String, ByVal value As String) As Integer
Dim conn As SqlConnection = New SqlConnection(ConnStr)
Dim strSQL As String = "UPDATE" + table + "SET" + strContent + "WHERE" + row + "=" + "" + value + ""
Dim myCommand As SqlCommand = New SqlCommand(strSQL, conn)
Dim count As Integer = 0
Try
conn.Open()
count = myCommand.ExecuteNonQuery()
Catch ex As SqlException
MsgBox(ex.ToString())
Finally
conn.Close()
End Try
Return count
End Function
Shared Function Search(ByVal ConnStr As String, ByVal strSQL As String) As DataTable
'创建SqlConnection实例
Dim conn As SqlConnection = New SqlConnection(ConnStr)
'创建SQL命令
Dim myCommand As SqlCommand = New SqlCommand(strSQL, conn)
'打开数据库连接
conn.Open()
'设置适配器
Dim adapter As New SqlDataAdapter
adapter.TableMappings.Add("Table", "TEMP")
adapter.SelectCommand = myCommand
'填充数据集
Dim ObjectdsDataSet As New DataSet()
adapter.Fill(ObjectdsDataSet)
'关闭数据库连接
conn.Close()
'返回查询的表
Return ObjectdsDataSet.Tables("TEMP")
End Function
求教啊,但为修改这个错误就忙了一个星期了,请高手帮忙啊 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询