0
下面的代码在第二个语句中给出了转换异常。从字符串“从tblCustMst中选择CustName”到“Integer”类型的转换无效
Dim query As String = "select CustName from tblCustMst " & "where [email protected]"
cmd.CommandType = query
下面的代码在第二个语句中给出了转换异常。从字符串“从tblCustMst中选择CustName”到“Integer”类型的转换无效
Dim query As String = "select CustName from tblCustMst " & "where [email protected]"
cmd.CommandType = query
您应该使用cmd.CommandText
。
试试这个:
Dim query As String = "select CustName from tblCustMst " & "where [email protected]"
cmd.CommandText= query
好运。
问题是当他将查询分配给CommandType时,更改为CommandText我打赌解决了他的问题 –
它在第二条语句 –
中给出错误,您不会将您的查询分配给CommandType。 CommandType是https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtype(v=vs.110).aspx –