How to get DataTable object from DB and get Values from it

Here the code I use ...

 

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

 

 

 

 

SqlDataAdapter Adptr = new SqlDataAdapter("Select * from AccountType ", con );DataTable mytbl = new DataTable("tbl");

Adptr.Fill(mytbl)

 

 

 

if (mytbl.Rows[0][1].ToString()) == "Classic")  /// Here I gey a message : There is no row 0 in table ....

I checked DataTable with Response.Write( mytbl.Rows.Count )  it gives me 0 ... What can be the problem ?


http://webdefence.info for those who develops and for those who hacks
0
mcguzic
6/5/2007 2:00:12 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
885 Views

Similar Articles

[PageSpeed] 47

You need a DataSet object when calling DataAdapter.Fill (not a DataTable).

DataSet ds = new DataSet();

Adptr.Fill(ds);

Then you can access the table by using ds.Tables[0]:

DataTable mytbl = ds.Tables[0];

0
tmmycat
6/5/2007 2:18:38 PM

Hi:

  Your code seems fine (if they are in one block). My only guess is there's no record in AccountType.

  If your problem isn't solved, please inform us.

Regards


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Allen
6/7/2007 3:02:29 AM
Reply:

Similar Artilces:

How do I get get values of controls inside datalist?
How do I get values of controls inside datalist?   For example, if I have a label inside header template or item template or footer template? Is there anyway to change property of label or any other controls inside those template as well? I would really appreciate if anybody can just post a sample code or a helpful link about datalist? Would really like to know more about the events fired for datalist, itembound, itemcreating etc?   hey there,I used this page to work out how to use datalists http://www.eggheadcafe.com/tutorials/aspnet/d89d1d96-03f1-4784-bbb2-a3db1af...

Getting DB control values
I have posted before about an approach to bring legacy Delphi apps to the web by encapsulating them in a shell. See http://84.86.145.75 This can work because the shell gets access to the controls on a form and the controls will reveal their visible footprint (normally a string but it can be an image as well). So far no obvious limitations have come up (it can cope with all the regular controls, allows for threads, modal forms, timer events, etc.) But I wonder now how to deal with TDBgrid and other DB controls. Since I have no experience with database apps at all, I have left thes...

POST GET GET GET GET... WTH?
Hi, I'm at a loss to explain this... I have an ASPX page that I can't always navigate to. When I developed the app (it's Starter Kit Portal-based), I did it on my LAN and have had no trouble accessing the page. However, upon deployment, I see the following behavior: 1. POST request goes out looking for MyForm.aspx 2. GET request for MyForm.aspx 3. GET request for MyForm.aspx 4. ... X. GET request Sometimes, the page finally loads. Other times, it just ends up blank. Many times, it doesn't load at ALL the first POST - I just get a "The pa...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Get value for each row in a DataTable object
I am really stacked on this one even though it seems to be so simple. I am not able to get the value of each row and store it array list all  I am getting is objects which I am not able to covert to array of strings. Anybody who can help me with this bummer? thank you      public static ArrayList GetExchangeGateways(DataTable tbl)    {        ArrayList list = new ArrayList();        foreach (DataRow r in tbl.Rows)        {  ...

To get the value of an object in a treeview control
hai all Please how can I get the value of a column other than in detail band in Tree view datawindow in ver 11.2 With thanks Polachan ---== Posted via the PFCGuide Web Newsreader ==--- http://www.pfcguide.com/_newsgroups/group_list.asp On Aug 7, 9:36=A0pm, "Polachan PP" <polacha...@yahoo.com> wrote: > hai all > > Please how can I get the value of a column other than in detail band in T= ree > view datawindow in ver 11.2 > > With thanks > > Polachan > ---=3D=3D Posted via the PFCGuide Web Newsreader =3D=3D---http://www.pfcg= u...

Get user input from dynamic created control, why i cant get the value???
Hi!, i was tried to dynamically generate some textboxes according the selected number in a dropdownlist, but when i need to get the user input from those textboxes.. i cant get at all!!, Can any1 guide me on tis? Below is my code.Basically, i have 1 dropdownlist (ddltbCount), 1 placeHolder(Pholder1), 1 button(btGetValue), i dont know y i cant post the html here... Private count As Integer = 1 Sub IterateThroughChildren(ByVal parent As Control) For Each c As Control In parent.Controls If c.GetType.ToString.Equals("System.Web.UI.WebControls.TextBox") AndAlso c.ID Is Nothing Then ' CType(c, T...

Unable to get values of a bounded control when postingback, How do I get previous state?
the second DDL doesn't work, cuz the items are refilled in the postback event.and of course if I fill in the items only if Not Page.IsPostBack, it doesn't fill anything. however, how can I get the previous DropDownList2 instantiated control, I mean I want to get the control as it would be looking before the user changed index + new selected index as an argument. or else - maybe I have to do it completely in a different way (?).  <%@ Page Language="VB" %> <%@ Import Namespace="System.Linq" %> <!DOCTYPE html PUBLIC "-//W3C/...

problem with get value from textbox after get it value in load page
hi every one  i have problem with my web site when i get textbox value in load page   and Changed textbox the page do not take last value .   it take value in load page   this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)   TextBox1.Text = "aa" End SubProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox(TextBox1.Text) End Sub   when i press button message write "aa" while i changed the textbox   please if enyone knowen help me &nbs...

TreeView Presentation Style help in getting the value of the object that represents the level clicked on.
Help I have the following heirarchy being represented in a treeview DW, based on a Stored Procedure level nameOfLevel dwo.name 1 vtkclient vtkclient_1 2 region region_1 3 mgmtco mgmtco_1 4 brand brand_1 detailband vtkclient, region, mgmtco, brand as invisible columns, and various other visible columns The screen is separated into two DWs, the left is the treeview, to the right is a list...

force a Linq-To-Entities query to get all related objects when getting a parent object
All -- Please help. How can one force a Linq-To-Entities query to get all related objects when getting a parent object? Is there a way to set the depth of the query? Please advise. For an example, check below for the code...   public Team.DynamicData01.Business.Entities.TestCoreRecord GetEntity(long targetId){ Team.DynamicData01.Business.Entities.TestCoreRecord myEntity = null;  using (Team.DynamicData01.Business.Entities.NorthwindEntityManager myContext = new Team.DynamicData01.Business.Entities.NorthwindEntityManager()) {  var q = from...

Query for substring to get some particular value in a string (Get querystring value by sql )
I have a column name URL in Table1 with data like  <a href="/Folder1/view_media_news.cfm?news_media_i=1">August 2002 Factsheet</a>            <a href="/Folder1/view_media_news.cfm?news_media_i=149">March 2002 Newsletter </a>  i need to grab the news_media_i value by sql query  Please any one can help me to get that particular value from string using substring or any other suggestion Thank you in advance SurendraIf this helps mark it as answer surendra_kla:i nee...

How to get the HREF value of the Anchor tag in a web page using the web browser control in vb.net
Hi Friends,               i have a webserver control in my application.i load the web browser control on a button click using the below code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click                AxWebBrowser1.Navigate("http://www.rateitall.com/i-322335-.aspx", False) End sub once the page is loaded in the browser i want the <a> HREF value in that page.For example if that page has ...

How get value from a dynamically created control in a user control
HI, I am working with a version of IBuySpy. On one page is a form that contains a user control that lists the items the user purchased, the subtotal, shipping, etc. I wanted to add a DropDownList from which the user could select the shipper. The dropdown list works fine as long as it has .AutoPostBack = false. However, I cannot figure out how to get the value that the user selected when they finally press the submit button on the form. All attempts to locate the control and it's value have failed. I tried drillingdown from the form to the child controls, and sub child controls. N...

Web resources about - How to get DataTable object from DB and get Values from it - asp.net.presentation-controls

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 325 ...

University of Southampton - Wikipedia, the free encyclopedia
The University of Southampton is a British Russell Group university located in the city of Southampton , United Kingdom . The origins of the ...

London Metropolitan University - Wikipedia, the free encyclopedia
London Metropolitan University (London Met), located in London , England , was formed on 1 August 2002 by the amalgamation of the University ...

Google Chart Tools — Google Developers
This page has moved to Google Developers. Welcome! Learn more Dismiss Home Products Events Showcase Google Chart Tools Overview Hello Charts! ...

Google Chart Tools — Google Developers
Powerful, simple to use, and free.

AribaWeb (aribaweb.org) - Google Groups
Search Images Maps Play YouTube News Gmail Documents More Calendar Translate Mobile Books Offers Wallet Shopping Blogger Reader Finance Photos ...

Linux Syscall Reference
Generated from Linux kernel 2.6.35.4 using Exuberant Ctags , Python , and DataTables . Developed and maintained by Greg Ose .

NewsMap
... over one weekend where the author had a bit of extra time on his hands. Built with the help of the following tools: Bootstrap jVectorMap DataTables ...

A Map for the Microsoft Application Development Platform
... Localization N-Tier Remote Data Security Silverlight SQL Azure SQL Server Streaming XML Features ADO.NET DataSet ADO.NET DataTable ...

Application Development Framework
Articles: Application Development Framework

Resources last updated: 1/17/2016 6:04:47 PM