-
Feb 11th, 2009, 08:35 AM
#1
Thread Starter
Lively Member
-
Feb 11th, 2009, 08:39 AM
#2
Re: Data Refresh
You haven't given enough (in fact, any) detail yet for us to be able to help.. please read the sticky thread Before You Post: Getting Database questions answered quickly (from the top of this forum) for the kind of info we need.
-
Feb 11th, 2009, 08:39 AM
#3
Re: Data Refresh
Change the location of the call to the data load. Maybe place it in the form Activate method.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 11th, 2009, 09:01 AM
#4
Thread Starter
Lively Member
Re: Data Refresh
sorry for not given enough detail ...
i mean when I put contact detail of database in the load event in form 1 and do editing in form2 the updated data will not change until I close form1 and reloaded again...
so I am asking for event to put contact detail of database which will be update databse from hide event to show event...
for example:Form1
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source =" & Application.StartupPath & "\db1.mdb"
Dim Conn As New OleDbConnection(ConStr)
Dim DataSet1 As New DataSet
Dim SQLstr As String = "SELECT * FROM Table1"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Conn.Open()
Dim DataAdapter1 As New OleDbDataAdapter(SQLstr, Conn)
DataAdapter1.Fill(DataSet1, "Table1")
Conn.Close()
TextBox1.DataBindings.Add("Text", DataSet1, "Table1.First_Name")
TextBox2.DataBindings.Add("Text", DataSet1, "Table1.Last_Name")
TextBox3.DataBindings.Add("Text", DataSet1, "Table1.CPR")
End Sub
for example:Form2
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class Form3
Dim frm As New Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As String = Me.TextBox3.Text
Dim SavInto As New OleDb.OleDbCommand
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & _
Application.StartupPath & "\db1.mdb"
Dim Conn As New OleDbConnection(ConStr)
SavInto.Connection = Conn
SavInto.CommandType = CommandType.Text
SavInto.CommandText = "UPDATE Table1 SET First_Name = '" & Trim(TextBox1.Text) & "' , Last_Name = '" & Trim(TextBox2.Text) & "' , CPR= '" & Trim(TextBox3.Text) & "' WHERE CPR ='" & n & "'"
Conn.Open()
SavInto.ExecuteNonQuery()
Conn.Close()
MsgBox("Edit Succeeded")
Me.Close()
frm.Show()
End Sub
End Class
I hope my Q is clear
-
Feb 11th, 2009, 09:27 AM
#5
Thread Starter
Lively Member
Re: Data Refresh
Originally Posted by GaryMazzone
Change the location of the call to the data load. Maybe place it in the form Activate method.
Thanks for reply GaryMazzone...
I've tried Activated event but it is not working with my form !
Code:
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source =" & Application.StartupPath & "\db1.mdb"
Dim Conn As New OleDbConnection(ConStr)
Dim DataSet1 As New DataSet
Dim SQLstr As String = "SELECT * FROM Table1"
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Conn.Open()
Dim DataAdapter1 As New OleDbDataAdapter(SQLstr, Conn)
DataAdapter1.Fill(DataSet1, "Table1")
Conn.Close()
TextBox1.DataBindings.Add("Text", DataSet1, "Table1.First_Name")
TextBox2.DataBindings.Add("Text", DataSet1, "Table1.Last_Name")
TextBox3.DataBindings.Add("Text", DataSet1, "Table1.CPR")
End Sub
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
|