Creating dataset, table adapter, binding source(...) and everything else in code
:wave: Hi!
Can you please explain me and/or show some good tutorials how to do it?
It seems pretty complicated because visual studio usually does it all for you and that made me stupid and not to do anything about it.
Things I don't know to do in code but I know VS does it for me:
-connection string
-dataset
-tableadapter
-bindingsource
-bindingnavigator
-table adapter methods and queries
...
I'm sure there is a good tutorial somewhere on the internet.
I'm okay with doing it with designer, but now when I have a situation where I can't use MDI container but tabcontrol.
Other solution would be to make a MDI container out of tabcontrol. Is it posible or only other form can be MDI container.
Thank you for your help and your time!
Re: Creating dataset, table adapter, binding source(...) and everything else in code
Sorry I'm posting again. I figured out that I can do everything on a "workspace", custom made user control but I had some problems with that:
-after closing and redimensioning the "workspace" (with dataset, datagrids and everything) my application crashes.
I believe that when I dispose the workspace, dataset doesn't become disposed.
If I could fix that, I wouldn't have to do anything in the code.
Re: Creating dataset, table adapter, binding source(...) and everything else in code
You don't create TableAdapters in code. TableAdapters are generated at design time. If you want to do it all in code then you use DataAdapters. All these things you're talking about are just classes, like any other. You create an instance in code using the New keyword to invoke a constructor, just like other classes. You set properties and call methods, just like other classes. They are also the same properties you set in the designer, e.g. the DataSource of a BindingSource.
For examples of how to write ADO.NET code, follow the Database FAQ link in my signature and check out the .NET resources there. Amongst others, you'll find a link to my Retrieving & Saving Data thread in the CodeBank.
Re: Creating dataset, table adapter, binding source(...) and everything else in code
:thumb:
Thank you! I will sure do read your database faq!
It's something that can't be learned totally intuitive and with no good literature.