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

Which code is better to use

13
hello all,

i am programming a webform which include a dropdownlist bind to DB to show the entries in a certain column in a table the user can chose an item and insert or update the tables I have two codes one thet used a dataset and the other code i used datareader to bind the list to the needed items and am not sure which one is beter to use in the webform


Expand|Select|Wrap|Line Numbers
  1.  
  2. MySqlDataAdapter depada = new MySqlDataAdapter("select * from dep1",con);
  3.     DataSet ds = new DataSet();
  4.     depada.Fill(ds);
  5.     lstdepa.DataSource = ds;
  6.     lstdepa.DataMember = ds.Tables[0].TableName;
  7.     lstdepa.DataTextField = "depname";
  8.     lstdepa.DataValueField = "depid";
  9.     lstdepa.DataBind();
  10.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. MySqlCommand MySqlComm = new MySqlCommand("SELECT * FROM dep", con);
  3.     con.Open();
  4.     ddDR = MySqlComm.ExecuteReader(CommandBehavior.CloseConnection);
  5.     lstdepe.DataSource = ddDR;
  6.     lstdepe.DataTextField = "depname";
  7.     lstdepe.DataValueField = "depid";
  8.     lstdepe.DataBind();
  9.     con.Close();
  10.  
Feb 19 '07 #1
3 1079
kenobewan
4,871 Expert 4TB
Define better... Have you tested them, does either of them work?
Feb 20 '07 #2
hime
13
Define better... Have you tested them, does either of them work?
Hi;

yes both codes does work but i need to know which one is more efficient for the program. i mean in which case should we use dataset and dataadapter and in which should we use datareader and command in other words i want to know exactly when to use each one of them

thanx
Feb 20 '07 #3
kenobewan
4,871 Expert 4TB
Here is an article that may help:
DataSet Vs. DataReader
Feb 21 '07 #4

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

Similar topics

17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
6
by: lastusernameleft | last post by:
i've been researching this issue for a while and can't come to any conclusive answer, mostly it seems to be a preference over syntax, some saying c# is elegant while vb is clunky, or that c# is...
17
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this...
9
by: Robert Lario | last post by:
C# verses VB.Net Which Way to go. I am sure this issues has come up before. Please direct me to any good articles that cover this issue. Ideally some neutral assessment.
53
by: Jon S via DotNetMonster.com | last post by:
Hi all, I'm planning on developing an ASP.NET web site. I know both VB.NET and C# but am unsure on which would be more useful to develop an ASP.NET site with? Also I maybe looking to become a...
13
by: cat_dog_ass | last post by:
Java is mature...however, a beginner may not stand any chance to compete against industry bigwigs. On the other hand, .NET is newer and gives newbies a relatively firm foothold, since there are...
25
by: rajus | last post by:
I have made a simple program to read the contents of a file.The FILE pointer returns NULL at the very beginning eventhough the file is present.Now if I modify my program and use command line...
6
by: Peter Proost | last post by:
Hi group, Which source code control program would you guys advice when working a lot with linked files in .net For example, I've got project A with its own frmA, frmB (linked from project B)...
3
by: =?Utf-8?B?Um9sYW5kcGlzaA==?= | last post by:
Hi, I'm doing an application using C# and I have this question: I have a method called sqlQueryBD which receives a string sql query and executes it against a database. I also have a class called...
20
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got the following C++ code. The first routine runs in...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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.