J
Jackjsmith88
Guest
Hi All,
Just wanted to ask a couple of questions to understand how it all works a little better?
So. i can see there are two main ways to get data into objects/controls on forms.
Method 1: use data config wizards to set connection to db file (now using MySQL) and generate bindingsources and tabeladapters
Method 2; Construct entirely from code, declaring string connection, creating New datasets and tableadapters and managing Fill() etc.
When i first starting playing, i used data config wizards.
Then i took an online lesson and constructed a connection and a fill() entirely by code.
However it seems as though, Using Method 1, its difficult to see whats going on because, at least with code, you can read what is happening. at the moment with method one, i'm not seeing any code that declares a connection string, or a dataset, they're just "there".
That isn't really helping me to understand what is going on and how it all clicks together.
But what about mix and match?
Lets say i set up everything using wizards, the dataset/tableadapter are all there waiting to be used. by default the form_Load has a This.Tableadapter.fill(This.Dataset.DataTable)
Now, i want to start playing with the tableadapter. its already been used to Fill in Form_Load. heres the tricky bit.
Basically, i want this form to load up, and attempt to read the data inside the dbfile. (which is empty) I want the form to Check for data. if no data then.
So my very little c# knowledge thought. Ok. for this i need to countRows. set countrows as 0 by default, and if countrows still = 0 after tableadapter.Fill() is called, then prompt to enter some details.
The details the person will enter, will be their name and address, and will be used as default on every subsequent execution of the program, (with an option to change these details of course)
This brings me back to previous problem. because the adapters/datasets are just there as opposed to being coded in, i'm struggling to work out how they're called and how to run additional functions through them. Please can someone tell me the best way forward? if i was attempt to code it, it would be like this, (baring in mind its in my dumb language and not a correct syntax)
Any advice as to which method is best? code it all, or use VS wizards?
I just dont like that in the VS wizards, you can't clearly see on the code what is happening, because .displaymember is just set in the wizard, not visible in code, if that makes sense?
Code:
int countrows = 0;
countrows = tableadapter.table.rows.count
And then something like:
Code:
if countrows =< 0 Then
Msgbox(No Default details are registered, please enter your details)
But i'm assuming i'd need to attempt to use a Try Statement? Never done it before.
im assuming its like, If /Else ? but instead its Try and Catch using {} to seperate right
If anyone has any ideas, i'd really appreciate your time and advice.
Thanks.
Jack
Continue reading...
Just wanted to ask a couple of questions to understand how it all works a little better?
So. i can see there are two main ways to get data into objects/controls on forms.
Method 1: use data config wizards to set connection to db file (now using MySQL) and generate bindingsources and tabeladapters
Method 2; Construct entirely from code, declaring string connection, creating New datasets and tableadapters and managing Fill() etc.
When i first starting playing, i used data config wizards.
Then i took an online lesson and constructed a connection and a fill() entirely by code.
However it seems as though, Using Method 1, its difficult to see whats going on because, at least with code, you can read what is happening. at the moment with method one, i'm not seeing any code that declares a connection string, or a dataset, they're just "there".
That isn't really helping me to understand what is going on and how it all clicks together.
But what about mix and match?
Lets say i set up everything using wizards, the dataset/tableadapter are all there waiting to be used. by default the form_Load has a This.Tableadapter.fill(This.Dataset.DataTable)
Now, i want to start playing with the tableadapter. its already been used to Fill in Form_Load. heres the tricky bit.
Basically, i want this form to load up, and attempt to read the data inside the dbfile. (which is empty) I want the form to Check for data. if no data then.
So my very little c# knowledge thought. Ok. for this i need to countRows. set countrows as 0 by default, and if countrows still = 0 after tableadapter.Fill() is called, then prompt to enter some details.
The details the person will enter, will be their name and address, and will be used as default on every subsequent execution of the program, (with an option to change these details of course)
This brings me back to previous problem. because the adapters/datasets are just there as opposed to being coded in, i'm struggling to work out how they're called and how to run additional functions through them. Please can someone tell me the best way forward? if i was attempt to code it, it would be like this, (baring in mind its in my dumb language and not a correct syntax)
Any advice as to which method is best? code it all, or use VS wizards?
I just dont like that in the VS wizards, you can't clearly see on the code what is happening, because .displaymember is just set in the wizard, not visible in code, if that makes sense?
Code:
int countrows = 0;
countrows = tableadapter.table.rows.count
And then something like:
Code:
if countrows =< 0 Then
Msgbox(No Default details are registered, please enter your details)
But i'm assuming i'd need to attempt to use a Try Statement? Never done it before.
im assuming its like, If /Else ? but instead its Try and Catch using {} to seperate right
If anyone has any ideas, i'd really appreciate your time and advice.
Thanks.
Jack
Continue reading...