473,574 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write SQL statement with LIMIT in it in Visual basic

58 New Member
Hi...every one...

I have a problem with below statement
selectstatement = "SELECT Messwert,UPLimW ert,LOLimWert,F ullname FROM abssubtest Where Fullname LIKE """ & Fullname & """ LIMIT 0, 5 "
here the underlined fullname is the item from combo box

If I have the same statement without LIMIT then the program is working...if it is with LIMIT I have some problem...is the statement I have given correct?...

if not can you plzz kindly give me suggestions of how to write an SQL statement with LIMIT in Visual Basic...

Thanks in Advance

Regards
SIva
Apr 21 '09 #1
3 5585
kadghar
1,295 Recognized Expert Top Contributor
perhaps you should use chr(34) instead of """

selectstatement = "SELECT Messwert,UPLimW ert,LOLimWert,F ullname FROM abssubtest Where Fullname LIKE " & chr(34) & Fullname & chr(34) & " LIMIT 0, 5 "
Apr 21 '09 #2
sivadhanekula
58 New Member
Hi...Thank you for the reply...

Problem is not with that...it is with LIMIT...if you look at the whole code...I have too many values in Fullname...but I want only the values of certain interval...and for that reason I have used LIMIT statement...but when I use this I am getting only one column and the other columns are nill...The column I am getting is Fullname with all names in it....without any limit....my question is...is there any particular format for addressing the LIMIT statement in vb 6.0...
Private Sub Okbutton_Click( )
On Error Resume Next

Dim Fullname As String
Dim CSV_line As String
'Dim Doublestring As String
Dim UppLimitstring As String
Dim Messwertstring As String
Dim LowLimitstring As String
Dim selectstatement As String
Dim Fullnamestring As String
Dim xs As Integer
Dim ys As Integer
Dim rs3 As Recordset

Fullname = FullnameList.Te xt
xs = x.Text
ys = y.Text


selectstatement = "SELECT Messwert,UPLimW ert,LOLimWert,F ullname FROM abssubtest Where Fullname LIKE " & Chr(34) & Fullname & Chr(34) & " LIMIT 0, 5 "

Set rs3 = db.OpenRecordse t(selectstateme nt)

Open "K:\user\Dhanek ula\Visual Baisc\file.csv" For Output As #1
Print #1, "Messwert;Upper Limit;Lowerlimi t;Fullname"

Do While Not rs3.EOF
Messwertstring = rs3.Fields("Mes swert")
LowLimitstring = rs3.Fields("LOL imWert")
UppLimitstring = rs3.Fields("UPL imwert")
Fullnamestring = rs3.Fields("Ful lname")
Messwertstring = Replace(Messwer tstring, ".", ",")
LowLimitstring = Replace(LowLimi tstring, ".", ",")
UppLimitstring = Replace(UppLimi tstring, ".", ",")
Fullnamestring = Replace(Fullnam estring, ".", ",")
CSV_line = Messwertstring & ";" & LowLimitstring & ";" & UppLimitstring & ";" & Fullnamestring '& ";"
Print #1, CSV_line
rs3.MoveNext
Loop
Close #1

End Sub
Apr 22 '09 #3
kadghar
1,295 Recognized Expert Top Contributor
I see, the problem has nothing to do with VB but with the statement you're sending to your DB Server.

Perhaps it's because some SQL Server versions dont support the LIMIT statement (just guessing). Why dont you try with something like SET ROWCOUNT 5.

HTH
Apr 22 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1742
by: chris | last post by:
I am nearing completion of writing a VB6 application. My main form is organized using a SSTab control, so you can imagine there are lots of controls on top of that. Much to my dismay I encountered this error a few minutes ago "Reached limit: Cannot create any more controls for this form". I looked that up and found that there is a limit of 255...
2
1746
by: http://www.visual-basic-data-mining.net/forum | last post by:
Hello, I have the following tables and have setup the following sql statement as part of my data adapter. The problem is that I need to do a statement that will find the records selected in my list box. I cannot figure out how to use the "name' alias in the parameter statement. I am trying to combine first, last name, alpha number into one...
11
1974
by: VB Programmer | last post by:
Is there a limit as to how big an aspx page's html can be? (number of characters) Why do I ask? I have a webform with a lot of ActiveX controls (shows up as OBJECT in html). When I place like 35 of these objects the form shows up BLANK in a web browser. When I remove a few (ANY few) I can see the page. Any ideas? Thanks.
4
2537
by: Christian Blackburn | last post by:
Hi Gang, I've created a text-based file format. Once I've generated the text to save the file is as it should be in the debug window. However once I write it to a file a " is added to the beginning and a ", to the end. Can somebody explain why? I'm using VB2003. Thanks in advance for any help, Christian Blackburn Here's my code:...
7
2615
by: Dr. Zharkov | last post by:
We have program Visual Basic .NET 2003 for construction of 3D-Graphics as a surface z=f (x, y). From VB .NET 2003 we want to transfer coordinates of this surface as myArrayVB (2000, 1) in myArrayVó of VC++ .NET 2003 on scheme of "component - client". But there are error 1 and error 2. For development of a component in VB .NET 2003 we...
2
1908
by: Luis Mendes | last post by:
How can I read and write images to SQL server to a field with the type "image". Can´t make DataBound work. Thank's in advance, Luis
3
6675
by: marknoten | last post by:
I'm quite a newbie to Visual Basic and have a problem with the Input # statement in the Visual Basic Editor from Excel. I would like to read in a tab delimeted text file selected by a user with records like this: <snip> O 21.266 17.733 28.155 N 20.649 17.703 30.320 C 20.883 17.336 31.723 </snip> I'm using the code below to read each line...
9
6924
by: andy.z | last post by:
If 2 people try to access the same text file at the same time to write to it - what happens in PHP ? What I mean is - presumably the first will be ok - But what will the second person actually see in his browser? And what will php do about it if not specifically programmed to deal with it ie whats the default behaviour?
0
779
by: Charlie Kent | last post by:
Thanks eBob I'm looking at what i wrote and figured out that I should just change the line I want to instead of just creating the file from scratch. So poking around I ended up finding a Search and replace piece and i'm using that. I'm not sure though if I should keep it as a class or do I build it right into the form? SO far I'm getting...
0
7736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8066
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8249
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8106
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5305
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3755
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2251
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1350
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.