Error in code

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.
 
S

S. Justin Gengo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,134
Latest member
Lou6777736
Top