I need to update table thru]ough VB.Net (.Net 2.0 framework) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

I need to update table thru]ough VB.Net (.Net 2.0 framework)

anshul_agraanshul_agra Posts: 12Member
i have to update the table entry for my table "user". I am running an update query through a tableadapter "usertableadapter1". The query is executing correctly but the records are updated only in the tableadapter not in the database. i tried to use "UserTableAdapter1.Update(UserDatabaseDataSet1.user)" statement but its of no use.
Please help me out how to reflect the changes made in the database.

waiting for you reply!

Comments

  • PavlinIIPavlinII Posts: 404Member
    : i have to update the table entry for my table "user". I am running an update query through a tableadapter "usertableadapter1". The query is executing correctly but the records are updated only in the tableadapter not in the database. i tried to use "UserTableAdapter1.Update(UserDatabaseDataSet1.user)" statement but its of no use.
    : Please help me out how to reflect the changes made in the database.
    :
    : waiting for you reply!
    :
    Hi,
    did you configured your dataadapter.UpdateCommand? Manually or using SqlCommandBuilder?

    Did you use DataSet.AcceptChanges for your table?
    Has the row you want to update Row.RowState=Modified?

    Do you really need DataAdapter to perform updates? I'm usually using own SqlCommand objects with SqlParameters to perform writebacks..

    Check theese points.

    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


  • anshul_agraanshul_agra Posts: 12Member
    : Hi,
    : did you configured your dataadapter.UpdateCommand? Manually or using SqlCommandBuilder?
    :
    : Did you use DataSet.AcceptChanges for your table?
    : Has the row you want to update Row.RowState=Modified?
    :
    : Do you really need DataAdapter to perform updates? I'm usually using own SqlCommand objects with SqlParameters to perform writebacks..
    :
    : Check theese points.
    :
    : [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
    :
    : [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]

    how can i configure dataadapter.UpdateCommmand?????
  • anshul_agraanshul_agra Posts: 12Member
    : : Hi,
    : : did you configured your dataadapter.UpdateCommand? Manually or using SqlCommandBuilder?
    : :
    : : Did you use DataSet.AcceptChanges for your table?
    : : Has the row you want to update Row.RowState=Modified?
    : :
    : : Do you really need DataAdapter to perform updates? I'm usually using own SqlCommand objects with SqlParameters to perform writebacks..
    : :
    : : Check theese points.
    : :
    : : [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
    : :
    : : [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
    :
    : how can i configure dataadapter.UpdateCommmand?????
    :
    and also i am using table adapter and datasets. Can you actually tell me the difference between table adapter and data adapter. I am very new to .Net programing so have no idea
  • PavlinIIPavlinII Posts: 404Member
    : : : Hi,
    : : : did you configured your dataadapter.UpdateCommand? Manually or using SqlCommandBuilder?
    : : :
    : : : Did you use DataSet.AcceptChanges for your table?
    : : : Has the row you want to update Row.RowState=Modified?
    : : :
    : : : Do you really need DataAdapter to perform updates? I'm usually using own SqlCommand objects with SqlParameters to perform writebacks..
    : : :
    : : : Check theese points.
    : : :
    : : : [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
    : : :
    : : : [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
    : :
    : : how can i configure dataadapter.UpdateCommmand?????
    : :
    : and also i am using table adapter and datasets. Can you actually tell me the difference between table adapter and data adapter. I am very new to .Net programing so have no idea
    :
    Hi,
    this is sample of using SqlDataAdapter for writebacks to database
    [code] Dim TA As New SqlDataAdapter("SELECT ID, Login, Name FROM Zamestnanci", PmLib.SQL.sqlConnStr)
    Dim CB As New SqlCommandBuilder(TA)
    Dim dTab As New DataTable("Zamestnanci")
    TA.Fill(dTab)
    dTab.Rows(0)(2) = "Pavlin II" [green]'Make some change[/green]
    TA.UpdateCommand = CB.GetUpdateCommand(True)
    TA.Update(dTab)
    dTab.AcceptChanges()
    dTab.Dispose()
    CB.Dispose()
    TA.Dispose()[/code]
    When you're using DataAdapter for writebacks, you have to configure UpdateCommand property.
    Select command can contains inner join over several tables and it's not exactness which column belonged to which table in original select.
    When you have simple table, you can use SqlCommandBuilder to generate update command automatically.
    You can explore DA.UpdateCommand.CommandText and .Parameters to view it's result.
    But I'd prefere manual writebacks to database (using SqlCommand object and own SQL)

    I do not know any TableAdapter or SqlTableAdapter (in .NET 2.0)..



    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


Sign In or Register to comment.