Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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
 
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
 
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
 
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.
 
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
 
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.
 
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.




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





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