Results 1 to 5 of 5

Thread: Binding Keywords/General Questions ADO.NET

  1. #1

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Binding Keywords/General Questions ADO.NET

    Hi all o7.

    I'm new to binding thing and have already watched few videos but they were all SQL based. I am using ADO.NET for its simplicity and being default on Visual Studio, Not an internet covered project, no need to any usernames and passwords and database is a *.mdb file. Fields are some integers and strings. Validating rules were somehow done.

    Am I using right things so far?

    2 main questions I have:
    I saw somewhere you can bind a textbox or a label to a field (or a column) called "first name" for instance. It suppose to show a row first name cell which you were clicked previously.

    You may also use "Binding Navigator" control which is a handy tool to sort of "roam around" the database.

    Now consider you have a lots of UserControls (in quantity of db rows). How to assign bindings or link them in UC design window, once you give it an address (row id or something else) they automatically gets/sets value to database (Duplex read/write)?

    I want it to be a real-time updatable table. Meaning that there is no save buttons to perform overwriting database. How to save or update in ADO.net? I accidentally here realized that "Copy to file location" should be false to achieve such thing but when there is no *.mdb file in my output folder, InitilizeComponent cannot fill the grid with my dataset.
    Last edited by pourkascheff; Oct 29th, 2023 at 04:47 AM. Reason: Visuals

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Binding Keywords/General Questions ADO.NET

    they were all SQL based
    I'm guessing that you actually mean that they were SQL Server-based. SQL is a language used by pretty much all databases, including Access. Many such databases even have "SQL" in the name, including MySQL, SQLite, PostgreSQL. Far too many people are lazy and refer to Microsoft SQL Server as just SQL and then it causes confusion when you assume that and people actually do mean just SQL. It's not hard to write SQL Server or, at the very least, MS SQL to avoid confusion.
    I am using ADO.NET for its simplicity
    Then you'll be using SQL to execute commands against your database. There are various ADO.NET proviuders for various databases and other data source, including SqlClient for SQL Server and OleDb for OLE DB data sources, including Access.

    As for your question, you bind user controls the same way you do any other control. You need a property to bind to and, if you want the data source to update when that property changes, a Changed event for the property. Let's say that you have a TextBox in your user control and you want to effectively bind to the Text property of it. You would need a property that exposes the Text of that TextBox and an event that's raised when the TextChanged event of that TextBox is raised. That might look like this:
    vb.net Code:
    1. Public Property TextBoxText As String
    2.     Get
    3.         Return textBox1.Text
    4.     End Get
    5.     Set
    6.         textBox1.Text = value
    7.     End Set
    8. End Property
    9.  
    10. Public Event TextBoxTextChanged As EventHandler
    11.  
    12. Protected Overridable Sub OnTextBoxTextChanged(e As EventArgs)
    13.     RaiseEvent TextBoxTextChanged(Me, e)
    14. End Sub
    15.  
    16. Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles textBox1.TextChanged
    17.     OnTextBoxTextChanged(EventArgs.Empty)
    18. End Sub
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Re: Binding Keywords/General Questions ADO.NET

    Long time no see sir, glad to see your reply first.
    It looks a bit confusing and vague at first sight. You also said this solution here for saving settings of specific control values within a series of User Controls. I migrated to database because I found that way very copy/pasty and complex. First teach me how to save/update/overwrite an dgv-edited loaded access database file on itself to achieve last edited data after shutdown reopen please.

    And yes SQL alone is a wrong term to use and we can see its name even when using ADO.NET in adapters and stuffs. I am using OLEDB.

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,508

    Re: Binding Keywords/General Questions ADO.NET

    First teach me how to save/update/overwrite an dgv-edited loaded access database file on itself to achieve last edited data after shutdown reopen please.
    This is a completely different question and you should create a new thread for it. Give a full explanation of your database and what you want to achieve. Post your current code and explain what problems your having.

    How you Add/Edit/Delete records will depend on your needs and how you've setup your database. Maybe Google "visual basic CRUD tutorial" there are lots of tutorials. CRUD = create, read, update and delete

  5. #5

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Re: Binding Keywords/General Questions ADO.NET

    EXACTLY!
    It isn't just a .Save() or .Update() or .AcceptChanges() to achieve that. It's more than that and depends on the way we choosed.

    My intention by "keywords" is someone explain to me the differences between DataBase, DataSource, DataSet, and DataAdapter, could be a good start. Everything got confusing dramatically when it comes to db.
    Last edited by pourkascheff; Oct 29th, 2023 at 03:59 PM. Reason: Visuals

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width