I have binded a textbox to a column in a SQL Server 2005 Database, when i fill the dataset it displays the data, but when i click the save button it doesn not save the changes to the database. I used this same code to do a Datagridview and it worked fine. Does anyone know what im doing wrong? Please advise.

Thanks in advance.

Imports System.Data.SqlClient
Imports System.Data
Imports System.IO


Public Class Form1
    Inherits System.Windows.Forms.Form

Private sqlconn As New SqlConnection("server=VSI-QA-03;Database=Database1SQL;integrated security=true")

    Private da As New SqlDataAdapter("Select * From Info", sqlconn)
    Private ds As New DataSet
    Private cmb As New SqlCommandBuilder(da)

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


        da.Fill(ds, "Info")
        txtFirstName.DataBindings.Add("Text", ds, "Info.FirstName")

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        da.UpdateCommand = cmb.GetUpdateCommand
        da.Update(ds.Tables("Info"))


    End Sub

    Private Sub txtID_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtID.TextChanged

    End Sub
End Class

Recommended Answers

All 2 Replies

Your code might be,

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

       da.Update(ds,"Info")
    End Sub

adatapost,

I changed the update code to what you suggested, but it still doesnt update.

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.