Connecting Tech Pros Worldwide Forums | Help | Site Map

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

lea
Guest
 
Posts: n/a
#1: Nov 22 '05

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


Aleksandr Sliborsky
Guest
 
Posts: n/a
#2: Nov 22 '05

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


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 ();


lea
Guest
 
Posts: n/a
#3: Nov 22 '05

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



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

Aleksandr Sliborsky
Guest
 
Posts: n/a
#4: Nov 22 '05

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


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
lea
Guest
 
Posts: n/a
#5: Nov 22 '05

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



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

lea
Guest
 
Posts: n/a
#6: Nov 22 '05

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



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

Closed Thread