1 Replies - 22604 Views - Last Post: 11 March 2012 - 05:14 AM Rate Topic: -----

#1 lakshmi10  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-February 12

how display data from database into textbox

Posted 10 March 2012 - 04:54 AM

I want to display a data from database into textbox in vb.net by giving a name.

In my database the values are

Subject
http://en.wikipedia.org/wiki/Oxford

Predicate
title

Object
http://www.country-regions.fake/oxford

I want to display a object in textbox by giving a predicate value as title

    Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\documents and settings\admin\my documents\visual studio 2010\Projects\WindowsApplication1\WindowsApplication1\db1.mdb")
    Dim cmd As New OleDbCommand
    Dim dr As OleDbDataReader
    Dim da As New OleDbDataAdapter
    Dim ds As New DataSet
    

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        con.Open()
        Try
            cmd = New OleDbCommand("select object from Table1 where predicate=title", con)
            da = New OleDbDataAdapter(cmd)
            da.Fill(ds, "Table1")
            textbox1.text = ds.Tables(0)
            Form5.Show()
        Catch ex As Exception
            MsgBox(ex.ToString())
        Finally
            con.Close()
        End Try
  


Is This A Good Question/Topic? 0
  • +

Replies To: how display data from database into textbox

#2 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: how display data from database into textbox

Posted 11 March 2012 - 05:14 AM

so where is the problem?

i can see you wont assign data table to textbox1.text.
textbox1.text = ds.Tables(0)

You can assign only one field to textbox1.text. Example:
textbox1.text = ds.Tables(0).Rows(?).Item(?)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1