Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to compare int values in VB.net?

Author  Topic 

RichardBone
Starting Member

29 Posts

Posted - 2006-11-11 : 01:23:39
Here is my statement:
Dim MyCommand As SqlDataAdapter
MyCommand = new SqlDataAdapter("select * from Request T1, Users T2 where RunID= "+ intRun_Num +" and T1.UserID = T2.UserID ORDER By Username", MyConnection)

I'm getting error saying:
Input string was not in a correct format.

the problem is the intRunNum. When I put intRunNum.toString(), there is no error but no results are coming up.

How do I get past this?

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-11-11 : 02:31:33
split your code into mutltiples lines, so by doing these it becamse easier to debug the error, what you are getting..?


Dim MyCommand As SqlDataAdapter
Dim strQuery As string
strQuery = "select * from Request T1, Users T2 where RunID= "+ intRun_Num +" and T1.UserID = T2.UserID ORDER By Username "



Now take the output of this query and run through query analyser, and check whether the error is due the query or due to some other formating issues in the front end.

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-12 : 20:10:33
Print the result of string and check if it correct. Also try using stored procedure with input parameters than using concatenated sql statements

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2006-11-13 : 13:34:39
The + is not the String concatination symbol for VB.net. You need to use &.

Try this:

Dim MyCommand As SqlDataAdapter
MyCommand = new SqlDataAdapter("select * from Request T1, Users T2 where RunID=" & intRun_Num.tostring & " and T1.UserID = T2.UserID ORDER By Username", MyConnection)


Also, you should try to avoid this sort of join syntax. Your Query would be best expressed as


SELECT t1.*, t2.*
FROM Request t1
INNER JOIN Users t2 ON t1.UserID = t2.UserID
WHERE t1.RunID = YourRunIDHere
ORDER BY t2.UserName


I'm guessing on what tables have the RunID and the UserName, so be sure to check that.
Hope this helps!
Michael

<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>

Opinions expressed in this post are not necessarily those of TeleVox Software, inc. All information is provided "AS IS" with no warranties and confers no rights.
Go to Top of Page
   

- Advertisement -