When executing the below code I get the following error.
"Additional information: Conversion from string "_01202478334" to type 'Double' is not valid."
Code:
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!!")
In order to troubleshoot I removed the CLI field, but then I get a new error
"Additional information: Operator '>' is not defined for type 'Date' and type 'Integer'"
I am using some very similar code on a separate form and it runs without any error.
Here is my working code:
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!!")
How come the code works on my other form, but not on this one?
NB. The SQL executes ok if I run the query direct from SQL server
Any help greatly appreciated