hello folks.
i have saved the values of
unique_ID.text
textbox1.text
textbox2.text
textbox3.text
textbox4.text
textbox5.text
textbox6.text
in columns
column_ID and column_1 to column_6
in a table table_1 in database db_1.

Now I want to update some values. but for that i want to show the values of column_1 to column_6 in textboxes
textbox1.text
textbox2.text
textbox3.text
textbox4.text
textbox5.text
textbox6.text
against a specific ID.

i can search specific ID entered in a textbox but the result is in datagridveiw which i dont want. i want them to fill the textboxes for updation. I hope i made clear the whole scene.

Recommended Answers

All 6 Replies

Loop through the Cells collection of the row you want to display and assign the value of each one to a textbox.

To make this easier you can load a List(Of TextBox) with the textboxes from the form and sort it by the names.

Now the index of the textbox in the list will correspond with the column index, and since the TextBoxes will be in the list by reference, what ever change you make to the textboxes in the list will be echoed on the form.

I love this tutorial, shows you lots of things about vb.net, including the solution to this thread. I wound up buying the ebook because it contains a couple more chapters that are not in the free online tutorial.

My solution is: Creating an array of buttons with your buttons then loop through it together with your SQL columns.

simple use datareader object to perform this operation , here is a sample code.

dim con = new sqlconnnection("connection string")
con.open()
dim cmd = new sqlcommand("select a ,b ,c ,d from table1 where id = " & txtId.text,con)
dim da = sqldatareader()
da = cmd.executereader()

while da.read()
    txtA.text=da["a"].Tostring()
    txtb.text=da["b"].Tostring()
    txtc.text=da["c"].Tostring()
    txtd.text=da["d"].Tostring()
end while

da.close()
con.close()

I typed code here so may be there are many spelling and other syntex mistakes are there as currently i am working in C# for 1.5 years so i just forget VB syntx. But here is an idea hope this will help you to solve your prob :)

Regards

thanks waqas bhai. it helped me alot in making sense of it.

@Zaki welcome brother :)

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.