Hi,
I am encountering the following error:
The code that I am using is:
From what I can see, my SQL statement is correct, and the connection is being opened correctly. The problem seems to occure when I try and assign the sql statement to the sqlconnection. The sqlconnection is defined as a new sqlconnection, and as a global variable.
Any suggestions??
Mike55
I am encountering the following error:
System.InvalidCastException: Cast from string "SELECT Email_Add FROM Login wher" to type Double is not valid. ---> System.FormatException: Input string was not in a correct format.
at Microsoft.VisualBasic.CompilerServices.DoubleType.Parse(String Value, NumberFormatInfo NumberFormat)
at Microsoft.VisualBasic.CompilerServices.DoubleType.FromString(String Value, NumberFormatInfo NumberFormat)
--- End of inner exception stack trace ---
at Microsoft.VisualBasic.CompilerServices.DoubleType.FromString(String Value, NumberFormatInfo NumberFormat)
at Microsoft.VisualBasic.CompilerServices.DoubleType.FromString(String Value)
at MsgWebService.moduleMessage.getSendersEmail(Int16 senderID) in c:\inetpub\wwwroot\MsgWebService\myModules\moduleMessage.vb:line 254
at MsgWebService.moduleMessage.sendMessage(DataRow messageDetails) in c:\inetpub\wwwroot\MsgWebService\myModules\moduleMessage.vb:line 133
at MsgWebService.wsSendMessages.sendMessage() in c:\inetpub\wwwroot\MsgWebService\wsSendMessages.asmx.vb:line 94
at MsgWebService.wsSendMessages.startProcessing() in c:\inetpub\wwwroot\MsgWebService\wsSendMessages.asmx.vb:line 57
The code that I am using is:
Code:
localConnection() Open a connection to the database.
Set-up the command
sqlCommand.Connection = conSQL
sqlCommand.CommandType = CommandType.Text
sqlCommand.CommandText = "SELECT Email_Add FROM Login where Group_HeadID = " + senderID
Try
getSendersEmail = sqlCommand.ExecuteScalar Execute the statement
Return getSendersEmail.ToString
Catch
Finally
conSQL.Close() Close the database connection.
End Try
From what I can see, my SQL statement is correct, and the connection is being opened correctly. The problem seems to occure when I try and assign the sql statement to the sqlconnection. The sqlconnection is defined as a new sqlconnection, and as a global variable.
Any suggestions??
Mike55
Last edited by a moderator: