473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

Hi...every one...

I have a problem with below statement
selectstatement = "SELECT Messwert,UPLimWert,LOLimWert,Fullname 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 5578
kadghar
1,295 Expert 1GB
perhaps you should use chr(34) instead of """

selectstatement = "SELECT Messwert,UPLimWert,LOLimWert,Fullname FROM abssubtest Where Fullname LIKE " & chr(34) & Fullname & chr(34) & " LIMIT 0, 5 "
Apr 21 '09 #2
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.Text
xs = x.Text
ys = y.Text


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

Set rs3 = db.OpenRecordset(selectstatement)

Open "K:\user\Dhanekula\Visual Baisc\file.csv" For Output As #1
Print #1, "Messwert;UpperLimit;Lowerlimit;Fullname"

Do While Not rs3.EOF
Messwertstring = rs3.Fields("Messwert")
LowLimitstring = rs3.Fields("LOLimWert")
UppLimitstring = rs3.Fields("UPLimwert")
Fullnamestring = rs3.Fields("Fullname")
Messwertstring = Replace(Messwertstring, ".", ",")
LowLimitstring = Replace(LowLimitstring, ".", ",")
UppLimitstring = Replace(UppLimitstring, ".", ",")
Fullnamestring = Replace(Fullnamestring, ".", ",")
CSV_line = Messwertstring & ";" & LowLimitstring & ";" & UppLimitstring & ";" & Fullnamestring '& ";"
Print #1, CSV_line
rs3.MoveNext
Loop
Close #1

End Sub
Apr 22 '09 #3
kadghar
1,295 Expert 1GB
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
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...
2
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...
11
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...
4
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...
7
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ó...
2
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
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...
9
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...

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.