Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 30th, 2004, 12:26 AM
Authorized User
 
Join Date: Jul 2004
Location: Delhi, Delhi, India.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default unable to display stored data in textbox(asp.net)

In which object
or data type i've to take the result of
the query,and then what value of that
object(data type) i've to assign to the
textbox.text.
pls send code for that in asp.net.

abhinavjain
__________________
abhinavjain
Reply With Quote
  #2 (permalink)  
Old July 30th, 2004, 03:14 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cairo, , Egypt.
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

most types you could view in textbox, what is the actual problems

Ahmed Ali
Software Developer
Reply With Quote
  #3 (permalink)  
Old August 2nd, 2004, 03:47 AM
Authorized User
 
Join Date: Jul 2004
Location: Delhi, Delhi, India.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

actual probleam is that ,i want to display the result of a select
query,from which i retrive 5-7 columns of a particular record, in the
textbox.
i have a basic idea for this
textbox.text=datatableobject.rows[0].column[..].tostring().
so what's the meaning of "datatableobject".

abhinavjain
Reply With Quote
  #4 (permalink)  
Old August 2nd, 2004, 05:01 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

abhinav,
for executing your query,do these steps....
1-first you should connect to your datasource(use SqlConnection objects).
2-make a new SqlCommand object and assign it your select query.(yourCommand.CommandText="select ....";)
3-make a new SqlDataAdapter object(new SqlDataAdapter(yourSqlCommandobject)).
4-make a DataSet object.
5-fill your dataset object through your SqlDataAdapter object(adapter.Fill(ds))
here you don't need again connect to your datasource,dataset object preserves your datasource in memory.
6-access the column you want in your DataSet and assign it to your textbox like something you know
textbox.text=DataSet.Tables[0].rows[number of row][number of column].tostring().(numberofcolumn is 5-7 according to your question)
****here DataSet.Tables[0] is equal to your DataTable object*****(it was the answer of your question)
DataSet object consists of DataTable objects,and also DataTable objects Consists of DataRow and DataColumn objects.....
Hope it was sufficient.

--------------------------------------------
Mehdi.
Reply With Quote
  #5 (permalink)  
Old August 2nd, 2004, 06:08 AM
Authorized User
 
Join Date: Jul 2004
Location: Delhi, Delhi, India.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was write this code, but it gives error
"Invalid attempt to read when no data is present."

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim conn As SqlConnection
        Dim sqlcommand1 As SqlCommand
        Dim ds As New DataSet()
        conn = New SqlConnection("Server=cabin30;uid=sa;pwd=;database =tms")
        conn.Open()
        sqlcommand1 = New SqlCommand("select top 1 Stu_Name from Stu_Info", conn)
        Dim adopter As New SqlDataAdapter(sqlcommand1)
        adopter.Fill(ds)
        TextBox1.Text = ds.Tables(0).Rows(0).Item("Stu_Name")
                conn.Close()
    End Sub

so what's the problem now.

abhinavjain
Reply With Quote
  #6 (permalink)  
Old August 2nd, 2004, 09:30 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

There is something wrong with your datasource.
No problem in your code.

--------------------------------------------
Mehdi.
Reply With Quote
  #7 (permalink)  
Old August 4th, 2004, 07:45 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

why dont u use DataBinding if u have DataSet?!

Always:),
Hovik Melkomian.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to validate data in ASP.net manojpatel ASP.NET 1.0 and 1.1 Professional 2 June 13th, 2006 02:31 PM
Unable to display data using drop down list hayley Classic ASP Databases 2 January 18th, 2005 05:36 AM
unable to display stored data(asp.net) Abhinav_jain_mca ADO.NET 3 August 3rd, 2004 03:33 AM
Unable to display data ractim ADO.NET 5 July 31st, 2004 04:55 AM
unable to print stored data in textbox(asp.net) Abhinav_jain_mca ADO.NET 1 July 30th, 2004 09:34 PM



All times are GMT -4. The time now is 03:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.