Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Error in code

Reply
Thread Tools

Error in code

 
 
=?Utf-8?B?SmFja08=?=
Guest
Posts: n/a
 
      09-14-2005
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.asp x.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.

 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      09-14-2005
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
"JackO" <> wrote in message
news:282470E5-A027-439E-9F2A-...
>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.asp x.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.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the difference between code inside a <script> tag and code in the code-behind file? keithb ASP .Net 1 03-29-2006 01:00 AM
A tool returned an error code from "Performing registration" error Wes Stebbins ASP .Net 1 07-15-2005 08:05 PM
Fire Code behind code AND Javascript code associated to a Button Click Event =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?= ASP .Net 4 02-11-2004 07:31 AM
Compiler Error Message: The compiler failed with error code 128. Yan ASP .Net 0 07-21-2003 10:49 PM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57