473,500 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

assigning, declaring and accessing dynamic variable

Hi all,

I am trying to create variables dynamically. This is needed because
the user interface can have ten different textboxes with name as txt1,
txt2 and so on. I would like to get values of all and then run in
single transaction.

for (int i = 1; i <= 10; i++)
{
(qry + i)= "insert into table1(field1) values(value1)";
}

This portion of declaring variable (qry + i) is not right and how can
I assign the dynamic variable here.

after creating the query string I want to execute as:
try
{
for (int i = 1; i <= 10; i++)
{
if (qry+ i.ToString != null) //same problem here
{
(qry + i.ToString).ExecuteNonQuery(); //same
problem here
}
}
}

Could you please tell me how I can achive what I am trying to do?

I do highly appreciate your help.
thanks a ton in advance.
best regards,
mamun

Mar 2 '07 #1
3 1794
On Mar 2, 12:27 pm, "mamun" <mamun...@hotmail.comwrote:
Hi all,

I am trying to create variables dynamically. This is needed because
the user interface can have ten different textboxes with name as txt1,
txt2 and so on. I would like to get values of all and then run in
single transaction.

for (int i = 1; i <= 10; i++)
{
(qry + i)= "insert into table1(field1) values(value1)";
}

This portion of declaring variable (qry + i) is not right and how can
I assign the dynamic variable here.

after creating the query string I want to execute as:
try
{
for (int i = 1; i <= 10; i++)
{
if (qry+ i.ToString != null) //same problem here
{
(qry + i.ToString).ExecuteNonQuery(); //same
problem here
}
}
}

Could you please tell me how I can achive what I am trying to do?

I do highly appreciate your help.
thanks a ton in advance.
best regards,
You want to look into the subjects of arrays and collections.

Mar 2 '07 #2
Hi Bruce,

Thanks for the reply. Can I do it without array?

Do you have any samples which I can look?
Thanks again,

mamun

Mar 2 '07 #3
On Mar 2, 2:32 pm, "mamun" <mamun...@hotmail.comwrote:
Hi Bruce,

Thanks for the reply. Can I do it without array?

Do you have any samples which I can look?
Why would you want to do it without using arrays? (Or, more properly,
collections in general, since an array is just one type of
collection.) An aggregate data structure (array or collection) is the
correct solution to the problem. Why make it hard on yourself?

Mar 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
4011
by: Friday | last post by:
Sorry if this is the wrong group. I tried to find the one I thought would be most relevant. I'm an old PHP guy, who knows little about asp and NOTHING about asp.net, but need to learn at least...
12
3920
by: bollod | last post by:
Is there any benefit to declaring a variable: x = (1<<12); instead of: x = 4096; (besides the geek appeal of course ;-) )
14
74745
by: Eric Bantock | last post by:
Very basic question I'm afraid. Once an array has been declared, is there a less tedious way of assigning values to its members than the following: myarray=8; myarray=3; myarray=4; myarray=0;...
8
1679
by: Ricardo Sta. Rita | last post by:
Hello people, We have been dealing with for a long time now. It's a bit weird for a newcomer like us so we decided to ask the geniuses here. C# doesn't seem to be assigning values, consider...
1
3106
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
20
6927
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
2
2964
by: Sike | last post by:
Hi everyone, I've been browsing this and a few other related newsgroups trying to get my head around this problem, and so far all the trails seem to go cold, without an acceptable solution being...
8
7495
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring and initializing variables inside a loop routine,...
1
4723
by: aresung | last post by:
Developed a web application in ASP.Net (Framework 1.0), in which I have used public variable which is defined in the aspx page and in the code behind will have some calculations and the ...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.