I have a small project which works with an Access 2003 database. It has some fields in text boxes, a few buttons and a datagridview. When I save the new record, I would like the datagridview to refresh as well. The searches I've come up with thus far show some very complex stuff which I don't think really apply for this simple a setup. Any advice would be appreciated.
Code:Imports System.Data.OleDb Public Class Form1 Dim dbname As String = "\\a_very_long_novell_path\CallLog.mdb" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'CallLogDataSet.CallLog' table. You can move, or remove it, as needed. Me.CallLogTableAdapter.Fill(Me.CallLogDataSet.CallLog) End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click Dim myConnection As OleDbConnection Dim myCommand As OleDbCommand Dim mySQLString As String Dim NTS As Integer = 0 Dim Detail As Integer = 0 Dim Auto As Integer = 0 myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbname & ";") myConnection.Open() mySQLString = "INSERT INTO CallLog (CallDate, Caller, Reason, DwgNo, AnsweredBy, TransferredTo)" & _ " Values ('" & DateTimePicker1.Text & "', " & _ "'" & UCase(txtCaller.Text) & "', " & _ "'" & UCase(txtCallReason.Text) & "', " & _ "'" & UCase(txtDwgNo.Text) & "', " & _ "'" & UCase(txtAnsweredBy.Text) & "', " & _ "'" & UCase(txtTransferredTo.Text) & "');" myCommand = New OleDbCommand(mySQLString, myConnection) myCommand.ExecuteNonQuery() MessageBox.Show("New Call Log has been added.", "Record Added") myConnection.Close() End Sub Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click Me.Close() End Sub Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click txtAnsweredBy.Text = "" txtCaller.Text = "" txtCallReason.Text = "" txtDwgNo.Text = "" txtTransferredTo.Text = "" DateTimePicker1.Text = Now End Sub End Class




Reply With Quote