Skip to main content

TextBox Control Using Datasets and Data Adapters


This tutorial is part of Database Programming Made Easy Series.

TextBox Control Using Datasets and Data Adapters

In this tutorial you'll learn how to retrieve and save data back to the database using Datasets and Data Adapters.

Microsoft Access database and Microsoft SQL Server sample is provided.

Previous: Using Data Readers and ExecuteNonQuery

Next: Windows Forms - ComboBox Control


Submitted byAnonymous (not verified)on Thu, 06/04/2009 - 14:46

Hero how about PSQL Sever can we connect. Please write for me Thank Hero NONG
Submitted byadminon Thu, 06/04/2009 - 21:02

In reply to by Anonymous (not verified)

Download ODBC Driver for Posgre SQL and change the connection string in the sample code.
Submitted byAnonymous (not verified)on Mon, 07/27/2009 - 20:18

I have made an oledb connection b/w mySQL & Visual c++ Windows form in VS 2005 and was successful in displaying the 5 fields of the db created in mySQL. I used the command this->oledbdataadapter1->(ds,"tablename"). But I'm deep trouble that i cannot procced ie; navigate the form using the buttons created even after trying lot many synatxes. Will you please help me out with the exact syntax/command by which i can get the navigation of fields done. The textboxes of these fields have already been correctly mapped to their 'text' field in databinding 'property' of each of them. Expecting a reply...and moreover I would be thankful to get a personal mail. [email protected] regards Bharat
Submitted byAnonymous (not verified)on Mon, 11/21/2011 - 06:36

Hi there, I know this is quite old but I've been searching for days on how to work visual basic and database, so far this is the best tutorial I've found, I'm new to programming, the only knowledge I know is things I've tried and learnt from tuts. My question is, How can I write the code so that I can search and retrieve information from the database but using any of the textbox controls I have. for instance I have 5 rows; costumer name, phone number, account number, msid, fees. with your code I can input the name and retrieve all the other info, but what if i want to search by phone number? or account number, or even msid? is it possible? and how? I tried
  1. If txtCName.text isNot "" Then
  2. Dim sqlQRY As String = "SELECT * FROM Customers WHERE CNAME = '" & txtCName.text & "'"
  3. Else If txtPhone.text isNot "" Then
  4. Dim sqlQRY As String = "SELECT * FROM Customers WHERE PNUMBER = '" & txtCName.text & "'"
  5. Else If txtAccount.text isNot "" Then
  6. Dim sqlQRY As String = "SELECT * FROM Customers WHERE ACCOUNT = '" & txtAccount.text & "'"
  7. End If
  8. '--then the rest of your code
  9. 'Create connection
  10. Dim conn As OleDbConnection = New OleDbConnection(cnString)
  12. Try
  13. ' Open connection
  14. conn.Open()
  16. 'create data adapter
  17. Dim da As OleDbDataAdapter = New OleDbDataAdapter(sqlQRY, conn)........
  20. But I get this error
  22. "Error 1 'sqlQRY' is not declared. It may be inaccessible due to its protection level. E:\Visual Basic Projects\WorkSummary\WorkSummary\FTMP.vb 44 63 WorkSummary"
  25. I appreciate all the help you can give me, thank you so much.

Add new comment