Click here to Skip to main content
15,913,773 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Dataset/DataAdapter and updating changes to the database.. Pin
ruanr27-Jan-10 0:38
ruanr27-Jan-10 0:38 
QuestionHow to detect a particular version of driver is installed on the PC when device is not connected. Pin
temp555626-Jan-10 12:31
temp555626-Jan-10 12:31 
QuestionRegQueryValueEx and REG_MULTI_SZ in Interop Pin
Alberto Bar-Noy26-Jan-10 7:42
Alberto Bar-Noy26-Jan-10 7:42 
QuestionAbout ComboBox re-population Pin
Hurricane300026-Jan-10 5:14
Hurricane300026-Jan-10 5:14 
AnswerRe: About ComboBox re-population Pin
Luc Pattyn26-Jan-10 6:18
sitebuilderLuc Pattyn26-Jan-10 6:18 
GeneralRe: About ComboBox re-population Pin
Hurricane300026-Jan-10 8:36
Hurricane300026-Jan-10 8:36 
GeneralRe: About ComboBox re-population Pin
Luc Pattyn26-Jan-10 13:26
sitebuilderLuc Pattyn26-Jan-10 13:26 
QuestionHow to refresh Database Connections Pin
akosidandan26-Jan-10 4:05
akosidandan26-Jan-10 4:05 
Hello,
I would like to ask how can I show what I have recently updated in my database
I just use textboxe's to show my data but my problem is that I does not show it yet
until I restart my program.Not like my delete command that it immediately affect
what changes I have made in the database.

Problem Conclusion:
How to immediately show changes made after updating the database

For more details below here are my codes:
My Declarations:
Dim con As New OleDb.OleDbConnection
    Dim da As New OleDb.OleDbDataAdapter
    Dim ds As New DataSet
    Dim dt As New DataTable
    Dim sSQL As String
    Dim maxRows As Integer
    Dim inc As Integer

My sub to display my database records to textbox:
Private Sub setRecords()
        Try
            'set the specific records 
            txtProduct_ID.Text = dt.Rows(inc).Item("productID")
            txtProductName.Text = dt.Rows(inc).Item("productName")
            txtProductDescription.Text = dt.Rows(inc).Item("productDescription")
            txtProductCategory.Text = dt.Rows(inc).Item("productCategory")
            txtProductStatus.Text = dt.Rows(inc).Item("productStatus")
            txtProductPrice.Text = dt.Rows(inc).Item("productPrice")
            txtProductQuantity.Text = dt.Rows(inc).Item("productQuantity")
            datePicker.Text = dt.Rows(inc).Item("productDateAdded")
            'disable editing when form in load
            txtProduct_ID.Enabled = False
            txtProductName.Enabled = False
            txtProductDescription.Enabled = False
            txtProductCategory.Enabled = False
            txtProductStatus.Enabled = False
            txtProductPrice.Enabled = False
            txtProductQuantity.Enabled = False
            datePicker.Enabled = False
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

MY code in update:
con.Close()

        Try
            con.Open()
            Try
                'add a new row 
                Dim Rows As DataRow
                Rows = dt.NewRow
                Rows.Item("productID") = Val(txtProduct_ID.Text)
                Rows.Item("productName") = txtProductName.Text
                Rows.Item("productCategory") = txtProductCategory.Text
                Rows.Item("productDescription") = txtProductDescription.Text
                Rows.Item("productStatus") = txtProductStatus.Text
                Rows.Item("productPrice") = Val(txtProductPrice.Text)
                Rows.Item("productQuantity") = Val(txtProductQuantity.Text)
                Rows.Item("productDateAdded") = datePicker.Text
                dt.Rows.Add(Rows)
            Catch ex As OleDb.OleDbException
                MsgBox(ex.ToString)
            End Try

            'save changes made to the database
            sSQL = "SELECT * FROM productTable"
            da = New OleDb.OleDbDataAdapter(sSQL, con)
            Dim cb As New OleDb.OleDbCommandBuilder(da)
            da.Update(dt)
            'move to last records of the database
            inc = -1
            If inc <> maxRows - 1 Then
                inc = maxRows - 1
                setRecords()
            End If
            con.Close()
            MsgBox("Records Succesfully Saved")
        Catch ex As OleDb.OleDbException
            MsgBox(ex.ToString)
        End Try
    End Sub

my code in delete:
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Dim a As MsgBoxResult
        a = MsgBox("Are you sure you want to delete this Record ?", MsgBoxStyle.YesNo + MsgBoxStyle.Critical, "Deleting Records")
        If a = MsgBoxResult.Yes Then
            Try
                Dim cb As New OleDb.OleDbCommandBuilder(da)

                dt.Rows(inc).Delete()
                maxRows = maxRows - 1

                inc = 0
                setRecords()
                da.Update(dt)
                MsgBox("Records Successfully Deleted")
                setRecords()
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
        Else
            MsgBox("Deleting Records have been canceled!")
        End If
    End Sub



Thanks,

dfan23
AnswerRe: How to refresh Database Connections Pin
Ciumac Sergiu26-Jan-10 6:59
Ciumac Sergiu26-Jan-10 6:59 
Questionhow to acess Control Reference in Thread Method Pin
shaina223126-Jan-10 2:58
shaina223126-Jan-10 2:58 
AnswerRe: how to acess Control Reference in Thread Method Pin
Jimmanuel26-Jan-10 3:11
Jimmanuel26-Jan-10 3:11 
GeneralRe: how to acess Control Reference in Thread Method Pin
Luc Pattyn26-Jan-10 3:30
sitebuilderLuc Pattyn26-Jan-10 3:30 
GeneralRe: how to acess Control Reference in Thread Method Pin
Jimmanuel26-Jan-10 3:53
Jimmanuel26-Jan-10 3:53 
QuestionSoftware Requirements Tool for .NET Pin
Calla25-Jan-10 21:16
Calla25-Jan-10 21:16 
AnswerRe: Software Requirements Tool for .NET Pin
Not Active26-Jan-10 1:46
mentorNot Active26-Jan-10 1:46 
GeneralRe: Software Requirements Tool for .NET Pin
Calla26-Jan-10 3:28
Calla26-Jan-10 3:28 
Questionwindows application Pin
mylogics25-Jan-10 20:40
professionalmylogics25-Jan-10 20:40 
AnswerRe: windows application Pin
Abhinav S25-Jan-10 20:58
Abhinav S25-Jan-10 20:58 
AnswerRe: windows application Pin
Mark Salsbery26-Jan-10 5:52
Mark Salsbery26-Jan-10 5:52 
Questiondisplay 60 questions with options Pin
Lakshmithangaraj24-Jan-10 23:13
Lakshmithangaraj24-Jan-10 23:13 
AnswerRe: display 60 questions with options Pin
Pete O'Hanlon24-Jan-10 23:18
mvePete O'Hanlon24-Jan-10 23:18 
AnswerRe: display 60 questions with options Pin
DeepakMega25-Jan-10 0:22
DeepakMega25-Jan-10 0:22 
Questionsample online quiz application Pin
Lakshmithangaraj24-Jan-10 23:08
Lakshmithangaraj24-Jan-10 23:08 
AnswerRe: sample online quiz application Pin
Ashfield27-Jan-10 2:57
Ashfield27-Jan-10 2:57 
Questionaccessing file contents from another system through streamreader-possible? plz help me, its urgent... Pin
thivya n24-Jan-10 22:07
thivya n24-Jan-10 22:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.