هذا اخواني هو الكود بالكامل و تحته سوف اكتب كودج الحفظ حفظكم الله و رعاكم
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & Application.StartupPath & "\Trouble_shooting.mdb"
Dim Conn As New OleDbConnection(ConStr)
Dim SavInto As New OleDb.OleDbCommand
Dim DataSet1 As New DataSet
Dim SQLstr As String = "SELECT * FROM log_file"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'TROUBLE_SHOOTINGDataSet.LOG_FILE' table. You can move, or remove it, as needed.
Conn.Open()
Dim DataAdapter1 As New OleDbDataAdapter(SQLstr, Conn)
DataAdapter1.Fill(DataSet1, "log_file")
Conn.Close()
TextBox1.DataBindings.Add("Text", DataSet1, "log_file.ref_no")
TextBox2.DataBindings.Add("text", DataSet1, "log_file.time")
TextBox3.DataBindings.Add("text", DataSet1, "log_file.date")
TextBox4.DataBindings.Add("Text", DataSet1, "log_file.reciver")
TextBox5.DataBindings.Add("Text", DataSet1, "log_file.caller")
ListBox1.DataBindings.Add("Text", DataSet1, "log_file.nature_of_fault")
ComboBox1.DataBindings.Add("Text", DataSet1, "log_file.substation_name")
TextBox6.DataBindings.Add("Text", DataSet1, "log_file.report_status")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
ListBox1.Text = ""
ComboBox1.Text = ""
Button1.Visible = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Form7.Show()
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
ListBox1.Enabled = True
ComboBox1.Enabled = True
Button1.Visible = False
Button3.Visible = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox2.Text = TimeOfDay
TextBox3.Text = DateString()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
ListBox1.Text = ""
ComboBox1.Text = ""
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
Dim SavInto As New OleDb.OleDbCommand
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & Application.StartupPath & "trouble_shooting\.mdb"
Dim Conn As New OleDbConnection(ConStr)
SavInto.Connection = Conn
SavInto.CommandType = CommandType.Text
SavInto.CommandText = "insert INTO log_file(ref_no,time,date,reciver,caller,nature_of_fault,substation_name,report_status)" & _
"values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & ListBox1.Text & "','" & ComboBox1.Text & "','" & TextBox6.Text & "') "
Conn.Open()
SavInto.ExecuteNonQuery()
Conn.Close()
MsgBox("save success")
Me.Close()
Me.Show()
Catch ex As Exception
Exit Sub
End Try
Button1.Visible = True
Button3.Visible = False
End Sub
End Class
و هذا كود الحفظ وحده عافاكم الله
Try
Dim SavInto As New OleDb.OleDbCommand
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & Application.StartupPath & "trouble_shooting\.mdb"
Dim Conn As New OleDbConnection(ConStr)
SavInto.Connection = Conn
SavInto.CommandType = CommandType.Text
SavInto.CommandText = "insert INTO log_file(ref_no,time,date,reciver,caller,nature_of_fault,substation_name,report_status)" & _
"values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & ListBox1.Text & "','" & ComboBox1.Text & "','" & TextBox6.Text & "') "
Conn.Open()
SavInto.ExecuteNonQuery()
Conn.Close()
MsgBox("save success")
Me.Close()
Me.Show()
Catch ex As Exception
Exit Sub
End Try
Button1.Visible = True
Button3.Visible = FalseEnd Sub
ارجو من الاخوة سرعة الرد علي حيث اني مبتدأ بهذا العلم مشكورين جميعا