I have been using the code below to edit SQL database fields from the data stored in a dataset. Problem is I have to repeat this long code for each database field to be edited....I find this very tiring...IS THERE A SHORTER WAY OF EDITING SQL Database FIELDS. (Am using VS 2005 and SQL Server 2005

'3. Create an Update command
            Dim strUpdateAccounts As String = "UPDATE Accounts SET Description = @Description"
            'create a SqlCommand object and assign it to the UpdateCommand property
            daDataAdaptor.UpdateCommand = New SqlCommand(strUpdateAccounts, con)
            'set up parameters in the sqlCommand object
            Dim param As SqlParameter

            '@Description
            param = daDataAdaptor.UpdateCommand.Parameters.Add(New SqlParameter("@Description", SqlDbType.VarChar, 150))
            param.SourceColumn = "Description"
            param.SourceVersion = DataRowVersion.Current

             'Update the database table with the dataset details
            daDataAdaptor.Update(dsDataSet, "Accounts")
            MsgBox(" Updated Sucessfully")

IMHO this is the more efficient way, if you want you can look up on Datagrids.

Thanks guys, guess I got to get used to is. Datagrids approach not very flexible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.