Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop sqldatacommand

Status
Not open for further replies.

dannG

Programmer
Jan 9, 2003
26
0
0
RO
Hy,

I have more than one data adapters in my form. Each data adapter has 4 data commands(insert, delete...).
How can I loop all the data comands in my form for setting some parameters?

thanks
 
I had try use a same parameter at both Update command and insert command in past,but the IDE show me a error that is the parameter is already use by another object.

you should be find a way about "dynamic create vb code" to resolve you problem.
 
Maybe you could try

Code:
Dim c as Control

for each c in Form1.Controls
   If Typeof c is SqlDataAdapter then
       'work with each type of command object individually
       CType(c, SqlDataAdapter).SelectCommand.Parameters...
   End If
next c

This will let you loop through all the data adapters quickly, assuming that the controls were added in form design mode. I don't know of any easy way to loop through each command object inside of each data adapter though.

Huel
 
Thanks huel, thanks 740520 (I hope is write!)
I'll try huel method. I have a lot of data adapters to a form and they recive the same parameter. That's way I need some kind of loop.
There is any container for this dataadapters? Or can I access the form component. Maybe this is the general ideea but I don't know how.
I'll post a result.
Thanks for the answer.
Have fun!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top