执行以下代码时,出现以下错误。
"Additional information: Conversion from string "_01202478334" to type 'Double' is not valid."
代码:
Using connn As New SqlClient.SqlConnection("server=inlt01\SQLEXPRESS; database=DaisyServices; integrated security=yes")
Using cmdz As SqlClient.SqlCommand = conn.CreateCommand()
cmdz.CommandText = "SELECT CLI, FromDate, ToDate, [Description], TotalCost, COUNT(*) as Count FROM [" + FileNameOnly + "] GROUP BY CLI, FromDate, ToDate, [Description], TotalCost HAVING COUNT(*) > 1"
connn.Open()
If cmdz.ExecuteScalar() > 1 Then
'Error if name in use
MessageBox.Show("Duplicate records exist on imported file!!")
为了排除故障,我删除了 CLI 字段,但随后出现新错误
"Additional information: Operator '>' is not defined for type 'Date' and type 'Integer'"
我在单独的表单上使用了一些非常相似的代码,它运行时没有任何错误。
这是我的工作代码:
Using connn As New SqlClient.SqlConnection("server=inlt01\SQLEXPRESS; database=DaisyBilling; integrated security=yes")
Using cmdz As SqlClient.SqlCommand = conn.CreateCommand()
cmdz.CommandText = "SELECT CustomerCLI, calldate, calltime, duration, TelephoneNumber, COUNT(*) as Count FROM [" + FileNameOnly + "] GROUP BY CustomerCLI, calldate, calltime, duration, TelephoneNumber HAVING COUNT(*) > 1"
connn.Open()
If cmdz.ExecuteScalar() > 1 Then
'Error if name in use
MessageBox.Show("Duplicate records exist on imported file!!")
代码怎么能在我的另一种形式上工作,但不能在这个形式上工作?
注意。如果我直接从 SQL 服务器运行查询,则 SQL 执行正常
非常感谢任何帮助