Results 1 to 6 of 6

Thread: populate values from a database!!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    populate values from a database!!

    Hi

    I need help to populate values from a database(Access) in to vb.net form. after selecting a field from first form , the next form should display all the parameters used in the selected field from the data base. Also if do editing it shppuld be updated in the database.


    Find the code below!!!
    Thanks in advance!


    Code:
    Public Class Editdetails
    
        Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Dim cn As New System.Data.OleDb.OleDbConnection
    
            Dim cm As New System.Data.OleDb.OleDbCommand
    
            Dim form As New Fielddetails
    
            Dim rd As System.Data.OleDb.OleDbDataReader
    
            Dim tbl_name As String = "Fld_detail_" & Datamaker.Application_Datamaker_ListBox.SelectedItem
    
            cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\175943\Desktop\database1.accdb;Persist Security Info=False;"
    
            Try
                cn.Open()
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
            cm.Connection = cn
            cm.CommandText = "select * from (" & tbl_name & ") where Start_loc like '" & form.ListBox_Fielddetails.SelectedItem & "%'"
            rd = cm.ExecuteReader()
            While rd.Read
    
                Me.datatype.SelectedItem = rd("Datatype").ToString
                Me.fieldname.Text = rd("Field_var").ToString
    
    
            End While
            rd.Close()
    
        End Sub

  2. #2
    Hyperactive Member Chathura's Avatar
    Join Date
    Nov 2005
    Location
    Sri Lanka
    Posts
    345

    Re: populate values from a database!!

    Is it working now?What is the problem now?
    If the post is heplful, Please Rate it
    Chathura Wijekoon

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    Re: populate values from a database!!

    no.its not working:-(

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    Re: populate values from a database!!

    Form is loading correctly... but the values are not populating from the database:-(

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    Re: populate values from a database!!

    Code:
    Me.datatype.SelectedItem = rd("Datatype").ToString
                Me.fieldname.Text = rd("Field_var").ToString

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,428

    Re: populate values from a database!!

    ramesh017,

    Have a look here.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width