hi everybody, i wish everything is okey? my question is

how i can the value of textbox show on colums in datagridview , my textbox read data from DB ??

thx before...

5 Years
Discussion Span
Last Post by Begginnerdev

yes that what i want and i want to display it when the form running..


can someone help me please i have a form that conatains a textbox and datagridview
the user enter the value in textbox then i need this value transfer to first cols in datagridview, what i can do, help plz


okey i use this code to display the value of text box on the datagrid but when i want to enter value on next col the data diappear, someone have an anser plz???

Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged

    For i = 0 To Me.DataGridViewBOQTY2.RowCount - 1
        DataGridViewBOQTY2.Rows(i).Cells(0).Value = projectboqtnocalculation.Text


End Sub

If you are not commiting the changes to the database on insert, then you will just refresh the data - erasing the values inserted on the next insert.

What database are you using?

What methods are you using to connect to the database?

Edited by Begginnerdev


no the value saved to database but when i want to enter the next value the prev one disappear. but its insert to database

i use conectionString and my DB sqlserver


I am trying to wrap my head around what you are wanting...

Are you:

A) Wanting to insert the value into the first column ( all rows ) then shift the columns right on the next insert


B) Wanting to create a new row with the value in the first column

If you are wanting A, you will have to create a new column for every entry.

If you are wanting B, you will have to create a new row for every entry.


If this is tied to a database, which it is, you will have to create a new column in the database every time you insert a value.

This is not a good thing, considered you could possibly have an infinitely increasing table.

Is it possible you can store the values in rows instead of columns?


Create an new entry in the database, then store the value into the coulmn specified:

If you are doing all the statements by hand, try something like this:

    Dim con As New System.Data.SqlClient.SqlConnection("connectionStringHere")
    Dim cmd As New System.Data.SqlClient.SqlCommand("INSERT INTO table1(column1) VALUES ('" & TextBox1.Text & "')", con)
Catch ex As Exception
End Try

Edited by Begginnerdev

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.