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
312 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
2 Comments
 
LVL 17

Expert Comment

by:Dushan911
Comment Utility
0
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 500 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now