473,624 Members | 1,999 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).Exe cuteNonQuery(); //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 1803
On Mar 2, 12:27 pm, "mamun" <mamun...@hotma il.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).Exe cuteNonQuery(); //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...@hotma il.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
4033
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 enough to convert a favorite PHP script to work on an ASP.NET site. I'm experimenting with simple example scripts that will help me learn how to implement each "piece" of the puzzle.
12
3934
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
74833
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; myarray=0; myarray=1; myarray=8;
8
1690
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 the lines of codes below: ------------------------------------------------ using Sem = semantics.SemanticsProcessingClass; ------------------------------------------------
1
3118
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 elements and would like to seek a solution for this. I had looked through several articles for accessing programatically-created dynamic elements such as: 1)
20
6953
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 = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
2
2974
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 reached. I'm posting here because there seems to be a few MVP's knocking around, and if they dont know, then it's a safe bet nobody does. I'm beginning to think that what I want to do is simply not possible - but i'll put it out there once...
8
7503
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, like this: for(var i=0; i<list; i++) { var name = list; }
1
4746
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 assign some value to that variable. Example: reports.aspx
0
8174
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8624
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7164
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.