Results 1 to 9 of 9

Thread: update and delete data

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    29

    Cool update and delete data

    Hi,

    i sorted the data when i configure the DataAdapter when load into the dataset as follow.

    SELECT CustNo, CustFName, CustLName, CustTitle, CustIC, CustDoB, Deposit, JoinDate, CustAdd_1, CustAdd_2, Postcode, City, State, HomePhone, WorkPhone, HandPhone, Email, Gender FROM Customers ORDER BY CustLName.

    i am having a problem of doing update and delete of the data in Customers. How do i solved these problems?? Please help.

    Thanks in advance,
    Viv

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    pls. post some code in your project for us to see..

    the select statement is not enough.

  3. #3
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    please post some code.

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    halu mate Andy looks like we post on time...lol

  5. #5
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    lol i saw that too

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: update and delete data

    Originally posted by vivsm


    i am having a problem ...
    How do i solved these problems??
    Telepathy?

  7. #7
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: Re: update and delete data

    Originally posted by mendhak
    Telepathy?
    my god...lol

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    29
    Guys,

    Sorry, my mistake !!!

    I am using ADO.Net. and i sorted the data by CustLName. The delete even is working but not deleted the correct data. The update even is not working at all.

    heres part of the code.

    Private cmCustomer As CurrencyManager

    Private Sub frmCustomers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Me.SqlDataAdapter1.Fill(Me.DataSet11.Customers)

    cmCustomer = Me.BindingContext(Me.DataSet11.Tables("Customers"))
    End Sub



    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

    If Me.cmCustomer.Position < 0 Then
    intResponse = MessageBox.Show("Database is empty !", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
    Exit Sub
    Else
    Try
    Dim intRowSwapper As Integer = Me.cmCustomer.Position - 1
    Me.cmCustomer.Position += intRowSwapper
    Me.SqlDataAdapter1.Update(DataSet11)
    MsgBox("Data Was SuccessFully Updated To The DataBase", MsgBoxStyle.Information, Me.Text)
    Catch
    End Try
    End If

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
    On Error GoTo fix

    Dim intResponse As Integer

    If cmCustomer.Position < 0 Then
    intResponse = MessageBox.Show("Database is empty !", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
    Exit Sub
    Else
    intResponse = MessageBox.Show("Are you sure want to delete this data ?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If intResponse = vbYes Then
    SqlConnection1.Open()

    If cmCustomer.Count > 0 Then
    Me.cmCustomer.RemoveAt(cmCustomer.Position)
    End If
    SqlDataAdapter1.Update(DataSet11)
    MsgBox("Data was successfully Deleted from DataBase", MsgBoxStyle.Information, Me.Text)

    SqlConnection1.Close()
    End If
    End If
    fix:

    Exit Sub

    End Sub

    Please help!!!
    viv

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    29
    Hi,

    i still cannot solve the problem. it always deleted the wrong data .

    Please help!!
    viv

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width