TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
theLizard
NA
3.5k
427.7k
Programming is your imagination to create something new.
Nov 26 2009 2:52 PM
@Kirtan this is original code by me to create a dynamic SQL update statement without any hard coding in the application, of course you cannot use this code without the thousands of other lines of original code used in developing the controls used to make this code work.
Controls like Text boxes, Combo Boxes that get data from an sql database
WITHOUT
being data bound, TreeViews that load data without hard coding, controls that finds ALL computers on a network, Controls that automatically moves to the next control in order of data entry
NOT
tab order but
ONLY
if it is allowed to , Combo and list boxes that are part of a data entry set who get their data from a lookup table without hard coding what to do with these when inserting or updating records in a database, Buttons that save, edit and delete records without hard coding by the developer.
Have you done anything similar.
internal string createUpdateWithValues(string groupName)
{
int gIndex = GetControlGroupIndexByName(groupName);
string setPart = "";
string equalPart="";
string ctrlName = "";
string value = "";
string sTmp="";
int start, end;
if(gn[gIndex].GroupSqlUpdate != ""){
setPart = gn[gIndex].GroupSqlUpdate;
start = setPart.IndexOf("SET") + 3;
setPart = setPart.Substring(start);
while(setPart.IndexOf("@") >= 0){ // as long as there is an @ in the string
//get = part of string
//get the control name from the string and strip the @ indicator
start = setPart.IndexOf("@"); //get ctrl name start
equalPart = setPart.Substring(0, start);
setPart = setPart.Substring(start);
start = setPart.IndexOf("@")+1; //get ctrl name start
end = setPart.IndexOf(",")-1; //get ctrl name end
if(end <= 0)
end = setPart.Length-1; //get ctrl name if no , found
ctrlName = setPart.Substring(start, end); //get value from ctrl
if(setPart.IndexOf(",") > 0)
setPart = setPart.Remove(start-1, setPart.IndexOf(",")+1);
else
setPart = setPart.Remove(start-1, setPart.Length);
value = getControlData(gIndex, ctrlName);
value = common.checkSingleQuote(value);
sTmp += equalPart + value + ",";
}
if(sTmp.Substring(sTmp.Length-1,1) == ",")
sTmp = sTmp.Substring(0, sTmp.Length-1);
setPart = sTmp;
//re-construct set statement
sTmp = gn[gIndex].GroupSqlUpdate.Substring(0, gn[gIndex].GroupSqlUpdate.IndexOf("SET"));
sTmp += "SET " + setPart;
// need to have a WHERE part
sTmp += " WHERE " + gn[gIndex].RecordIdFieldName + " = " + gn[gIndex].GroupRecordId;
gn[gIndex].GroupSqlInsert = sTmp;
}
return(sTmp);
}
Reply
Answers (
0
)
Placing Data from a Dataset table directly into SQL
How to become a good in c #?