Error in code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am experiencing an error when I run the following code:

Dim dsServer As New DataSet
Dim cmdServer As New SqlCommand
Dim sSelect As String = "SELECT tblServer.DNSName FROM tblServer WHERE
tblServer.IPAddress = " & Integer.Parse(Request.QueryString("ID"))

cmdServer.CommandText = sSelect
cmdServer.Connection = SqlConnection1

Dim daServer As New SqlDataAdapter

daServer.SelectCommand = cmdServer
daServer.Fill(dsServer)

Exception Details: System.Data.SqlClient.SqlException: Syntax error
converting the nvarchar value '10.1.30.130' to a column of data type int.

Source Error:


Line 43: Dim daServer As New SqlDataAdapter
Line 44: daServer.SelectCommand = cmdServer
Line 45: daServer.Fill(dsServer)
Line 46: Dim serverRow As dsServer.tblServerRow
Line 47: txtDNSName.Text = serverRow.DNSName


Source File: c:\inetpub\wwwroot\ITApplications\ServerDetail.aspx.vb Line:
45

Since I am only selecting one field which is a varchar field
(tblServer.DNSName) in my select statement, I am not sure why this is
happening. Any help would be appreciated.
 
JackO,

You are telling your program to convert the passed in string to an integer.
Integers don't have decimal points...

You'll need to use a different data type.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Back
Top