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 –