Update data in datagrid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shil

    #1

    Update data in datagrid

    Hi all,

    I am working on a .net app using Framework 1.1
    I have a datagrid which is getting data from a dataset, that is bound
    to multiple tables.
    Basically I have a datagrid, a textbox and a button the form. What I
    would like to do is bind data to datagrid and get one of the field from
    datasource to display in the text box just below the datagrid. I want
    to edit existing rows both in datagrid and textbox, when the button is
    pressed, the data should be save to database. Is there any way to
    accomplish this? I searched all forums but couldn't find any solution
    to accomplish this.
    My Form_Load code is as below
    *************** *************** *************** *****
    Dim strConn = "Server=localho st;Database=TRA SAR2;User
    ID=sa;Password= nlasalle120;"
    Dim myConn As SqlConnection = New SqlConnection(s trConn)
    Dim myDs As DataSet = New DataSet

    Dim Sql As String
    Sql = "SELECT DISTINCT CustomerName, FacilityName, ControllerName,
    LastName+' '+FirstName UserName, UserType, EmailAddress As Email1,
    Email1Alarms,Em ail2, Email2Alarms, Email3, Email3Alarms, EmailList,
    a.UserID, d.ControllerID FROM UMaster_New a INNER JOIN CustMaster b ON
    a.CustomerID=b. CustomerID INNER JOIN FMaster c ON
    b.CustomerID=c. CustomerID INNER JOIN CMaster_New d ON
    c.FacilityID=d. FacilityID INNER JOIN CAccess e ON
    d.ControllerID= e.ControllerID AND a.UserID=e.User ID"

    myConn.Open()
    Dim myDa As SqlDataAdapter = New SqlDataAdapter( Sql, myConn)
    myDa.SelectComm and.CommandType = CommandType.Tex t
    myDa.Fill(myDs, "Users")

    DataGrid1.DataS ource = myDs.Tables("Us ers")
    TextBox1.DataBi ndings.Add("Tex t", myDs.Tables(0), "EmailList" )

    myConn.Close()
    *************** *************** *************** *****
    My app needs the data to be updated to UMaster_New table and to
    CMaster_New table.

    Thanks in advance.

Working...