# Datagrids and Textboxes

**URL:** <https://forums.thehomestack.io/t/datagrids-and-textboxes/109>\
**Category:** vb.Net\
**Created:** [January 2, 2004, 7:40am UTC](https://forums.thehomestack.io/t/datagrids-and-textboxes/109 "2004-01-02T07:40:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://forums.thehomestack.io/uploads/default/original/1X/161426793bc0d8bdf0d1a6692b3e44446861cc72.jpeg) [@system](https://forums.thehomestack.io/u/system)\
**Post date:** [January 2, 2004, 7:40am UTC](https://forums.thehomestack.io/t/datagrids-and-textboxes/109/1 "2004-01-02T07:40:01Z")

</div>

To retrive the data to unbound textboxes it goes as follows:

```auto
        
       With datagrid 
            textbox1= .Item(.CurrentCell.RowNumber, 0) 
            textbox2= .Item(.CurrentCell.RowNumber, 1) 
        End With 

```

If you want to update the database, well there’s 2 ways. An update command in your code or a stored procedure in the db that you call. Stored procedures are much more efficient so I always use them.

Stored procedure way:

```auto
 
        Dim sql_Conn As New SqlClient.SqlConnection(ConnectionString) 
        Dim sqlcmd_Make As SqlCommand = New _ 
            SqlCommand("UPDATE_MAKE", sql_Conn) 

        With sqlcmd_Make 
            .CommandType = CommandType.StoredProcedure 

            With .Parameters 
                .Add("@MAKE_ID", SqlDbType.VarChar, 12).Value = l_l_MakeId 
                .Add("@DESC", SqlDbType.VarChar, 15).Value = tbMake.Text 
            End With 
        End With 

        sql_Conn.Open() 
        sqlcmd_Make.ExecuteNonQuery() 

```

what I think the in code update way is:

```auto

        Dim sql_Conn As New SqlClient.SqlConnection(ConnectionString) 
        Dim sqlcmd_Make As SqlCommand = New _ 
            SqlCommand("update command", sql_Conn) 

        sql_Conn.Open() 
        sqlcmd_Make.ExecuteNonQuery() 

```

to refresh your datagrid without going from scratch:

```auto

    dataset.Clear() 
                sqladapter.Fill(dataset, "TABLENAME")

```
