-
Jan 24th, 2010, 11:57 PM
#1
Thread Starter
Lively Member
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
-
Jan 25th, 2010, 04:58 AM
#2
Hyperactive Member
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
-
Jan 25th, 2010, 05:13 AM
#3
Thread Starter
Lively Member
Re: populate values from a database!!
-
Jan 25th, 2010, 05:25 AM
#4
Thread Starter
Lively Member
Re: populate values from a database!!
Form is loading correctly... but the values are not populating from the database:-(
-
Jan 25th, 2010, 05:26 AM
#5
Thread Starter
Lively Member
Re: populate values from a database!!
Code:
Me.datatype.SelectedItem = rd("Datatype").ToString
Me.fieldname.Text = rd("Field_var").ToString
-
Jan 25th, 2010, 05:37 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|