Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello awesome programmers.
I am stuck in a problem, I want to Loop through my database's specific table because I have setup some textboxes to calculate the value. Let me Explain in steps:
I want this with my program when i launch it.
Step 1: Run Program
Step 2: Program Loop through table and pick first and place it's values in textboxes as usual
Step 3: Run my custom defined function or anything i have coded with some of those textboxes
Step 4: Save/Update data of the first entry which our program picked earlier.
Step 5: Repeat All Steps again until all Table entries picked.
Step 6: Now show the main interface of our program.


That's it.
I know it's very complicated but Excuse my English and i want solution.
Thanks in advance.

What I have tried:

I have tried nothing because i dont know how to loop through entry by entry in a table.
Posted
Updated 7-Oct-20 19:57pm
Comments
Sandeep Mewara 8-Oct-20 1:47am    
And what is the issue? Where are you stuck when you started writing code?

1 solution

Try something like:
VB
Using con As New SqlConnection(strConnect)
	con.Open()
	Using cmd As New SqlCommand("SELECT ID, Description FROM myTable", con)
		Using reader As SqlDataReader = cmd.ExecuteReader()
			While reader.Read()
				Dim rowID As Integer = CInt(reader("ID"))
				Dim rowDesc As String = reader("Description").ToString()
				Console.WriteLine($"ID: {rowID}, {rowDesc}")
			End While
		End Using
	End Using
End Using
 
Share this answer
 
Comments
Member 13490734 8-Oct-20 8:56am    
Bro my connection is from Access not from Sql :(
OriginalGriff 8-Oct-20 9:10am    
1) If you are using a specific database, you need to tell us. Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
2) I'm not your "bro".
3) So use an OdbcConnection and the associated Command, DataAdapter, DataReader, etc. constructs instead of SqlConnection. You are supposed to think about the code you are given / find, not just blindly stuff it into your app and hope it works out of the box!
Jason Elliott 2022 2-Dec-22 16:01pm    
I'm not your buddy, guy.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900