473,378 Members | 1,364 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,378 software developers and data experts.

multiple resultset

js
I am using the Microsoft.Practices.EnterpriseLibrary and trying to bind
all the DropDownList controls on a page by calling the following
function at Page_Load event. My attempt is make only one trip to the
SQL Server and populate all the result sets in a Datasset object then
bind each DropDownList to the repective table. How can I achieve this?
As you can see, I execute SQL statement multiple times in the sample.

private void bindDropDownListControls()
{
try
{
DataSet ds;
Database db = DatabaseFactory.CreateDatabase();
string sqlCommandMake = "Select Make, Make + ',' + cast(MakeId as
varchar(20)) as MakeValue from Make;";
string sqlCommandType = "Select Type, Type + ',' + cast(TypeId as
varchar(20)) as TypeValue from Type;";
string sqlCommandModel = "Select Model, Model + ',' + cast(ModelId
as varchar(20)) as ModelValue from Model;";

string sqlCommand = sqlCommandMake + sqlCommandType +
sqlCommandModel;

DBCommandWrapper dbCommandWrapper =
db.GetSqlStringCommandWrapper(sqlCommandMake);

//It would be nice to use GetSqlStringCommandWrapper(sqlCommand)
//then bind the DropDownList's DataSource to ds("tableName")

cboMake.DataSource = db.ExecuteDataSet(dbCommandWrapper);
cboMake.DataTextField = "MAKE";
cboMake.DataValueField = "MakeValue";
cboMake.DataBind();
cboMake.Items.Insert(0,"");

dbCommandWrapper = db.GetSqlStringCommandWrapper(sqlCommandType);

//I am trying to avoid execute another command, instead
//it would be nice to access the second table in the ds since it
//contains all the results already.

cboType.DataSource = db.ExecuteDataSet(dbCommandWrapper);
cboType.DataTextField = "TYPE";
cboType.DataValueField = "TypeValue";
cboType.DataBind();
cboType.Items.Insert(0,"");

dbCommandWrapper = db.GetSqlStringCommandWrapper(sqlCommandModel);
cboModel.DataSource = db.ExecuteDataSet(dbCommandWrapper);
cboModel.DataTextField = "MODEL";
cboModel.DataValueField = "ModelValue";
cboModel.DataBind();
cboModel.Items.Insert(0,"");

}
catch(InvalidCastException e)
{
lblError.Visible = true;
lblError.Text = e.Message;
}
}

Nov 19 '05 #1
0 966

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

Similar topics

0
by: RoyalScorpion | last post by:
hi guys, i get an updatable resultset from a connection then used it to insert a new row but the result set doesn't chane after insertion, i mean the no of rows before insertion is the same after...
0
by: Ralph Freshour | last post by:
I'm not sure the follow multiple table query is the right way to do what I need to do although it seems to be working: $php_SQL = "SELECT * ". "FROM basics, personal, photos ". "WHERE...
4
by: randy.p.ho | last post by:
Using JDBC, is there a way to call a stored procedure with multiple return values? Thanks.
3
by: Joe via DotNetMonster.com | last post by:
Hi, I'm trying to use several select statements so that I don't need to call the function several times. The next Result set always seems to read the first select statement. I have the...
4
by: _link98 | last post by:
Problem: java ResultSet cursor from SQL/PL stored-procedure is FORWARD_ONLY. Is it possible to have ResultSet cursors from SQL/PL procedures to scroll forward and backwards? Perhaps I am missing...
2
by: Diego | last post by:
Hi everybody! I'm using DB2 PE v8.2.3 for linux. I've defined a database with the following schema: ANNOTATION(ID,AUTHOR,TEXT) ANNOTATION_BOOK(ANNOTATION_ID,OBJECT_ID)...
2
by: thetaamommy | last post by:
Hi All : CREATE TABLE TABLEA(Person Varchar(20), Country Varchar(20), Subject Varchar(20), Type Char(1)) INSERT INTO TABLEA VALUES ('Einstein', 'Germany', 'Physics', 'P') INSERT INTO TABLEA...
0
by: Camfa | last post by:
Hi all, I’ve been messing around with the following question for 2 days now, and i still haven’t find a fix. So i hope you can help me. I’ll quickly show you guys the situation: There are 2...
1
by: sarathkals | last post by:
Does any one know what r the Disadvantages of Mars(multiple active resultset). please help me thanx in advance for any help sarath
5
by: =?Utf-8?B?TWlrZSBE?= | last post by:
This is a difficult question: I need to be able to input data via hand-scanner into a web page textbox, but it needs to be done more than once. The user will scan one card after another and in the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.