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
316 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:Dushan De Silva
ID: 38717711
0
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 500 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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