We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,707 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

SQL Query

halo guys, I having problem executing the SQL statement in the visual studio but when in the MySQL it work fine. Here are my code.

   Dim sql As String = "SELECT * FROM (SELECT @row:= @row + 1 AS rowNum, std.* FROM Student std ,(SELECT @row:= 0) r) AS t where rowNum = " & i & ""

Please help.thanks

4
Contributors
4
Replies
17 Hours
Discussion Span
1 Year Ago
Last Updated
5
Views
mancode1007
Newbie Poster
16 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

In English, what is your query supposed to do and what happens when you run it?

Reverend Jim
Carpe per diem
Moderator
3,590 posts since Aug 2010
Reputation Points: 561
Solved Threads: 445
Skill Endorsements: 32

It would help to know the error or the exact nature of the "problem" you are having and possibly know how you are trying to use this string.

As a rule of thumb when having problems executing a command in a different system, start by verifying the command you are sending. ie debug.print sql instead of executing it (or when you get the error) and copy/paste the output from the immediate pane to your db and make sure your statement is correct.

adam_k
Veteran Poster
1,057 posts since Jun 2011
Reputation Points: 274
Solved Threads: 205
Skill Endorsements: 11

I was once asked (by the maintainer of an in-house app), why his SQL query ran so slowly. I had a look at it and was appalled to see that the query consisted of almost 20 lines of concatenated text. I asked him what the query was supposed to do and he couldn't tell me.

Which is why I want to know what it is you are trying to do so I can possibly suggest a simpler alternative.

Reverend Jim
Carpe per diem
Moderator
3,590 posts since Aug 2010
Reputation Points: 561
Solved Threads: 445
Skill Endorsements: 32

It would be great if you could post the error as with just one line of sql, I have no idea what you are doing wrong.

Since you said that the sql works, I am guessing you did not add value into your parameter in your sql?

Also, since you are using parameters sql, why did you not just sent the i variable as a parameter as well?

Dim sql As String = "SELECT * FROM (SELECT @row:= @row + 1 AS rowNum, std.* FROM Student std ,(SELECT @row:= 0) r) AS t where rowNum = " & **i **& ""

To:

"SELECT * FROM (SELECT @row:= @row + 1 AS rowNum, std.* FROM Student std ,(SELECT @row:= 0) r) AS t where rowNum = @rownNum"

wen_cai
Junior Poster in Training
64 posts since May 2012
Reputation Points: -3
Solved Threads: 17
Skill Endorsements: 2

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0621 seconds using 2.64MB