|
-
Jan 12th, 2007, 11:17 AM
#1
Thread Starter
Member
[RESOLVED] Add New Code
Hey everybody. I am somewhat new to DB programming, and I am struggling to get a grasp on the fundamentals.
I am trying to write the code the VB generates when you drag a table onto a form. The specific code I am looking for is the code that controls the "ADD NEW" plus symbol button on the binding navigator toolbar that pops up. I feel if I can get a good idea of the code behind these things, I will be on the right track.
If anyone can help, it would be highly appreciated.
Thanks
-
Jan 12th, 2007, 11:40 AM
#2
Re: Add New Code
Do you mean the code that defines the form itself? I'm not sure why you'd want to look at this but you can just open the form object in wordpad to see all hidden code.
-
Jan 12th, 2007, 11:50 AM
#3
Thread Starter
Member
Re: Add New Code
I am looking for the code that comes along with the autogenerated toolstrip that appears on the form when you drag a table from the datasources onto the form.
I would like to see the code because I want to model other code on its functionality.
I have tried opening it in Notepad, but I see the same code as in VB code window. I know the "Add New" button has code behind it, as it has functionality. I just cant find this code.
Thanks for your help.
-
Jan 12th, 2007, 11:57 AM
#4
Re: Add New Code
Are you using Classic VB (VB6 and earlier) or VB.Net (VB 200x)?
If you are using Classic VB, you cannot get the code.. but you can have a much better alternative that has fewer problems - which is to use code to work with database rather than the controls. See the ADO Tutorial link in my signature for explanation/example.
-
Jan 12th, 2007, 12:10 PM
#5
Re: Add New Code
I've been waiting for someone to ask these questions, but since no one has, I will.
I have no idea what you are referring to. Is this an Access database?
 Originally Posted by theun789
I am trying to write the code the VB generates when you drag a table onto a form.
What VB generated code? How do you "drag" a database table onto a form?
What is an "autogenerated toolstrip"?
What "Add New" button?
-
Jan 12th, 2007, 12:12 PM
#6
Thread Starter
Member
-
Jan 12th, 2007, 12:14 PM
#7
Re: Add New Code
What type of database are you using?
-
Jan 12th, 2007, 12:21 PM
#8
Thread Starter
Member
Re: Add New Code
Sorry for being unclear. I am working in VB2005 Standard Edition.
I am connected to a remote SQL database on a server.
Within my program I have a dataset that refernces the tables in the database.
Using VB2005, I am able to drag a table from the Data Sources sidebar onto a form. When I do this, VB creates the neccesary connections, and adds either a datagrid view, or details view (w/ text boxes). It also adds a navigating toolbar to the top of the form. This toolbar has left, right, first, and last navigation buttons to go between existing records. It also has a save button which will propogate changes back to the database. There is an additional button on this toolbar, an "Add new" button. I am trying to find what the code behind this button would be. In essence, it initializes a new row in the table, and then allows the user to enter the neccesary data. This is the code I would like to undertand.
Thanks to everyone for your help so far
-
Jan 12th, 2007, 12:39 PM
#9
Re: Add New Code
AddNew is a SQL Insert statement. The "Save" button is a SQL Update statement. (That may not be the actual code the controls generate, but it's how you code AddNew and Save.)
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jan 12th, 2007, 12:43 PM
#10
Thread Starter
Member
Re: Add New Code
So the setup I have currently consists of a combobox bound to the Primary key of the table. As I change the selected index, the text boxes below update to reflect the data corresponding to the chosen row.
I want to code a button that will initiate this insert command you refer to. IE combobox will have next value (it is auto-incremented) and the text boxes will be open for data.
Any help on how to code this?
Thanks
-
Jan 12th, 2007, 04:54 PM
#11
Thread Starter
Member
Re: Add New Code
The code I was looking for turned out to be rather simple.
Me.ClientBindingSource.AddNew()
Sorry for any wasted time, and thanks for the help.
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
|