By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

Documents on MDI forms with Dataset?

P: n/a
al
Greetings,

Thanks in advance for your kind attension.

I have been searching for documents about dynamically coding MDI forms
when working with datasets. Does anyone know of any???

MTIA,
Grawsha
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"al" <gr*********@yahoo.com> schrieb

I have been searching for documents about dynamically coding MDI
forms when working with datasets. Does anyone know of any???


Apart from <F1> I don't know any documents. ;-)

Do you have a specific question? Maybe I can help.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
al
"Armin Zingler" <az*******@freenet.de> wrote in message news:<uv**************@TK2MSFTNGP11.phx.gbl>...
"al" <gr*********@yahoo.com> schrieb

I have been searching for documents about dynamically coding MDI
forms when working with datasets. Does anyone know of any???


Apart from <F1> I don't know any documents. ;-)

Do you have a specific question? Maybe I can help.


I basically look for a way to avoid hard coding column names in the
SQL statement when I send changes (delete,udate and insert) back to
the database(i'm still working on the logical development. of the
app). The case is like thsi: I have a MDI form with a couple of
children forms(employees and customers). The related datatables(dt) in
the dataset(ds) is filled from database when its related form is
first loaded(table customer is filled when form customer is first
loaded). I refer to AciveMdiChild.Text in the MDI parent to load that
child form.

User, say, deletes a record by clicking a button to send the changes
to the database. There will be one button (on the toolbar of MDI
parent)for each operation (delet, update and insert). Now, my
problem comes when I try to write the SQL statement to send changes
back to database. That is, I don't want to hard code the column name
like this:

Dim str as String="Delete from employees where employeeID=@employeeid"

This will force me to write another SQL stat. for the the customers
form, which I do not want to do.

In this string, I was able to substitute the table name with the
ActiveMdiChilde.Text property. Now, to substitue the column name, I
look at the location of the related column name in the underlyning
datatable in the dataset, but the problem this column(usually Primary
Key,PK) does not have fixed location(it might be col 0 in one
employees table but col 1 in customers table ) or it might be 2
columns in some cases.

This is still hard coding the location of the column name:

Dim str as String="Delete from" & ActiveMdiChild.Text & " where " &
ds.tables _(ActiveMdiChild.Text).Columns(0).ColumnName & "=@" &
ds.tables _(ActiveMdiChild.Text).Columns(0).ColumnName

How should I DYNAMICALL refer to the location of the column name in
the underlyning datatable??
Should I use class or interface or what??? Remember, the
ActiveMdiChild is a basic form with basic properties,i.e., I can't
refer to labels or textboxes of the child form. ONLY names,text,etc..

MTIA,
Grawsha
Nov 20 '05 #3

P: n/a
Cor
Hi Al,

A dataset is never doing things with the MDI form direct but always with
controls placed on it, which can interact with dataset.

Therefore I do not see why there should be an answer for your question, can
you explain it something more?

Cor
I have been searching for documents about dynamically coding MDI forms
when working with datasets. Does anyone know of any???

Nov 20 '05 #4

P: n/a
"al" <gr*********@yahoo.com> schrieb

I have been searching for documents about dynamically coding
MDI forms when working with datasets. Does anyone know of
any???


Apart from <F1> I don't know any documents. ;-)

Do you have a specific question? Maybe I can help.


[...]
How should I DYNAMICALL refer to the location of the column name
in the underlyning datatable??
Should I use class or interface or what??? Remember, the
ActiveMdiChild is a basic form with basic properties,i.e., I can't
refer to labels or textboxes of the child form. ONLY
names,text,etc..


I don't think there is a short answer that explains the details. I can only
give a general answer: I'd store the information on a table somewhere and
pass it to each child. How this can be done is an individual design
question - and I'm usually getting paid for more details. ;-) If you've got
all information about the structure of the table in a DataTable, you can
dynamically built the Form, the SQL and whatever, based on this information.
For example, you can use a loop to process all columns, to build the SQL
string and to fill the Parameters. If you use a Commandbuilder, it's
(usually) sufficient to build the select string and the other SQL strings
(update/delete) are built for you.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

P: n/a
al
"Cor" <no*@non.com> wrote in message news:<#S**************@TK2MSFTNGP12.phx.gbl>...
Hi Al,

A dataset is never doing things with the MDI form direct but always with
controls placed on it, which can interact with dataset.

Therefore I do not see why there should be an answer for your question, can
you explain it something more?

Cor
I have been searching for documents about dynamically coding MDI forms
when working with datasets. Does anyone know of any???

Hello Cor,

The basic delma i'm facing comes from two sides. One is User
Interface (UI) requirments and second to be effeciant with coding.
For the first part, there is supposed to be only one button(on toolbar
of the MDI parent) for each database operation. One button to do only
one job(button for update, another for insert and third for delete),
so that both forms use it, or for as many forms as needed, for this
matter. This leads to the second part of the problem. That is, say a
user clicks the delete button, this forces me to have IF condition to
test for the ActiveMdiChild and see which of the children forms is
active. This way I will have to hard code for all of the children
forms. I don't want to that!
Now, having said that, I want to be more specific to get the "big
picture".
With the delete operation , for example,I use SQL statement to send
chagnes to DB.

"Delete from employees where employeeid=@employeeid"

If I do something like this, then i have to do it for all child forms.
What I want is to write ONE delete statement for all forms, i.e.,
DYANMIC one.
I was able to produce the following to get ONE dynamic SQL statement
for All child forms:

NOTE:
************************************************** ****************************
ActiveMdiChild.Text reads the child form's TEXT property, which is the
same as the table name in the dataset,i.e., customers form has
CUSTOMERS name as its text
************************************************** *****************************

IF Me.Toolbar.button.text = "Delete" Then

"Delete from" & ActiveMdiChild.Text & " where" & ds.tables
(ActiveMdiChild.Text).Columns(0).ColumnName & "=@" &
ActiMdiChi.Text.Column (0).ColumnName

End If

Here, I don' know how to create the dyanmic column location, instead
of hardcoding the location to 0.
Grawsha
Nov 20 '05 #6

P: n/a
Cor
Hi Al,

I type it in here not in the designer so check it good

I have still to asume a lot but I see you use a dataset, I start asuming
that you use datagrids or something and that you want to delete a row from a
dataset from which you know the dataset row.

I think you can than use a shared class for this
\\\
public class Al
public shared sub AlsDelete(byval ds as dataset, byval tabl as string,
byval row as integer)
ds.tables(tabl).rows(row).delete
end sub
end class
///
And then when you want to delete a row
\\\
IF Me.Toolbar.button.text = "Delete" Then
Al.alsdelete(ds,"ActiveMdiChild",rowposition)
End If
///
You can give it a try.

Cor
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.