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.

SELECT * FROM[Table]WHERE field BETWEEN...

lea

Does anyone know how to write the
SELECT * FROM tblename WHERE fldname BETWEEN combobox1.text AN
combobox2.text
i can't find much source about this query on net,i need to let use
select category to print report.Please help me,THank

--
le
-----------------------------------------------------------------------
lea's Profile: http://www.msusenet.com/member.php?userid=156
View this thread: http://www.msusenet.com/t-187052994

Nov 22 '05 #1
5 1706
May be so... (for oledb provider)
OleDbConnection conn = new OleDbConnection (connStr);
string cmdText = "SELECT * FROM tblename WHERE fldname BETWEEN @begintext
AND @endtext";

OleDbCommand cmd = new OleDbCommand (cmdText, conn);
cmd.Parameters.Add ("begintext", combobox1.text);
cmd.Parameters.Add ("endtext", combobox2.text);
conn.Open ();
// Or You may fill in dataset using dataadapter
OleDbDataReader reader = cmd.ExecuteReader ();

while (reader.Read())
{
// do what You want
}
reader.Close ();
conn.Close ();
Nov 22 '05 #2
lea

thank you! i solved the problem.but is there possible to insert all th
"dr.item" into database before the datareader.close(between whil
dr.read and end while)? i facing problem state that should close th
connection and recreate a new connection for the INSERT INTO query. bu
what i want is retrieve the record(i did it) and INSERT the records tha
i retrieve into a temporary table for printing purposes(crysta
report).
instead of using the method that i mentioned above, is there any othe
way to print the records that i retrieved

--
le
-----------------------------------------------------------------------
lea's Profile: http://www.msusenet.com/member.php?userid=156
View this thread: http://www.msusenet.com/t-187052994

Nov 22 '05 #3
Sorry, but i don;t understande Your message clear.... :(
I'll answer what I understood:
At first You don't need to close a connection to insert raws into some
table, just close reader...

Second, if You want just to create temporary table, you can use following
approach:

OleDbConnection conn = new OleDbConnection (connStr);
string cmdText = "SELECT * FROM tblename WHERE fldname BETWEEN @begintext
AND @endtext";

OleDbCommand cmd = new OleDbCommand (cmdText, conn);
cmd.Parameters.Add ("begintext", combobox1.text);
cmd.Parameters.Add ("endtext", combobox2.text);
OleDbDataAdapter dbAdapter = new OleDbAdapter (cmd);
DataTable tempTable = new DataTable ();
dbAdapter.Fill (tempTable);
conn.Close ();
tampTable - is what You need
Nov 22 '05 #4
lea

erm... this concept is quite close to what i post. :) but my project du
date is 15/JUN. I'd Pass up my system. Im using crystal report, but i
show all the data in the table.. this is not what i want. but time i
limited. However, thanks for your help, i will try this code after m
exam! :rolleyes: THANKS!

--
le
-----------------------------------------------------------------------
lea's Profile: http://www.msusenet.com/member.php?userid=156
View this thread: http://www.msusenet.com/t-187052994

Nov 22 '05 #5
lea

erm... this concept is quite close to what i post. :) but my project du
date is 15/JUN. I'd Pass up my system. Im using crystal report, but i
show all the data in the table.. this is not what i want. but time i
limited. However, thanks for your help, i will try this code after m
exam! :rolleyes: THANKS!

--
le
-----------------------------------------------------------------------
lea's Profile: http://www.msusenet.com/member.php?userid=156
View this thread: http://www.msusenet.com/t-187052994

Nov 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michel | last post by:
How to select all lines containg a string (located in $pastmove) in the moves column I tried several ways, for example: $requete="SELECT moves, opening_id FROM suitemove where moves like...
3
by: Nicolae Fieraru | last post by:
Hi All, I try to build an asp page and I try to execute this sql string: dim weight weight = CLng(Request.Form("Weight") strQ = "SELECT * FROM tbFreightPrices WHERE MinWeight < weight"...
0
by: John | last post by:
Why does a select from table with an integer field return a row if I compare the integer to an alpha character? Here's the info ( a straight copy and paste), then compare my two select...
4
by: lea | last post by:
Does anyone know how to write the SELECT * FROM tblename WHERE fldname BETWEEN combobox1.text AND combobox2.text i can't find much source about this query on net,i need to let user select...
9
by: saturnius | last post by:
Hello, I am passing a value to a stored procedure in vb.net to get normally a selection of the table. How could I get the complete table without writing the code twice? Many thanks in advance ....
2
by: pagoto123 | last post by:
select * from table where director = '" & Director.text & "' i want to display me all results that start with the director that the user will enter........ please i need the command help me...
2
bilibytes
by: bilibytes | last post by:
Hi, i'm having some problems in making a specific query: I want to get all the fields where column = 'value' AND (id <= "number" AND id >="number") is there a predefined statement to do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.