|
-
Oct 29th, 2023, 04:39 AM
#1
Thread Starter
Hyperactive Member
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
-
Oct 29th, 2023, 08:02 AM
#2
Re: Binding Keywords/General Questions ADO.NET
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:
Public Property TextBoxText As String
Get
Return textBox1.Text
End Get
Set
textBox1.Text = value
End Set
End Property
Public Event TextBoxTextChanged As EventHandler
Protected Overridable Sub OnTextBoxTextChanged(e As EventArgs)
RaiseEvent TextBoxTextChanged(Me, e)
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles textBox1.TextChanged
OnTextBoxTextChanged(EventArgs.Empty)
End Sub
-
Oct 29th, 2023, 01:10 PM
#3
Thread Starter
Hyperactive Member
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.
-
Oct 29th, 2023, 03:08 PM
#4
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
-
Oct 29th, 2023, 03:55 PM
#5
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|