HI...:)
what is the event which refresh data instead of load event !
I mean the data will be refresh every time when the form event change from hide to show !?
Any idea please...:confused:
Regrads...:)
Printable View
HI...:)
what is the event which refresh data instead of load event !
I mean the data will be refresh every time when the form event change from hide to show !?
Any idea please...:confused:
Regrads...:)
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.
Change the location of the call to the data load. Maybe place it in the form Activate method.
sorry for not given enough detail ...:o
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
for example:Form2Code: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
I hope my Q is clear:confused: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
Thanks for reply GaryMazzone...:)Quote:
Originally Posted by 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