Armin Zingler said:
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