?
Solved

How would you insert records into a SQL Server table via a loop using C# when comparing a field to an incremented variable?

Posted on 2012-12-23
2
Medium Priority
?
318 Views
Last Modified: 2012-12-27
I am developing a C# Windows platform application using VS2005.
I am also using SQL Server 2005 tables as the back end database.

How would you code a loop so that the int variable intBranch, is incremented by 1 starting with the initial value of 001 through 999 and for each value, intBranch
is compared to the value of field Left([CPS Account Number],3) of table tblFlLNExp.

If Left([CPS Account Number],3) of table tblFlLNExp = intBranch
then

INSERT INTO tblFlLNMod SELECT tblFlLNExp.*   FROM
tblFlLNExp WHERE LEFT([CPS Account Number],3 = intBranch
0
Comment
Question by:zimmer9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 38717711
0
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 2000 total points
ID: 38717825
if tblFlLNExp is a table in the database then you have to make sql statement to retrive its data
and store it in a data table

example

dim dt as new datatable
dt=get the data from database()
then you have to loop through your datatable and compare it with your value
0

Featured Post

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question