|
-
Jun 9th, 2003, 04:38 PM
#1
Thread Starter
Lively Member
SQL / C# Question! *Resolved*
Hello,
This is a snippet from my code, I do this several times! I was just wondering if anyone had a suggestion for a simpler way to do the following:
Code:
case "address_map":
RS = DB.Execute(myData.pService.SQL_ADDRESS_MAP_CHECK.Replace("%1", A[1]), out ob, -1);
if (!RS.EOF)
{
Out_Data += "error ";
}
else
{
DB.Execute("insert into address_maps (Mail_Box_ID, Email, Status, Misc) Values('" + A[2] + "','" + A[3] + "','" + A[4] + "','" + A[5] + "')", out ob, -1);
Out_Data += "good ";
}
Send(Out_Data + Environment.NewLine);
break;
case "domain":
RS = DB.Execute("select domains.Domain_ID, domains.Domain, domains.Post_Office_ID, domains.Status, domains.Misc from domains where domains.Domain = '" + A[2] + "'", out ob, -1);
if (!RS.EOF)
{
Out_Data += "error ";
}
else
{
DB.Execute(myData.pService.SQL_DOMAIN_CHECK.Replace("%1", A[2]).Replace("%2", A[3]).Replace("%3", A[4]).Replace("%4", A[5]), out ob, -1);
Out_Data += "good ";
}
Send(Out_Data + Environment.NewLine);
break;
Thank YOU!!!
Mitchel
Last edited by toto; Jun 11th, 2003 at 06:49 PM.
-
Jun 11th, 2003, 05:15 PM
#2
Lively Member
Code:
switch (Whatever) {
case "address_map":
RS = DB.Execute(myData.pService.SQL_ADDRESS_MAP_CHECK.Replace("%1", A[1]), out ob, -1);
break;
case "domain":
RS = DB.Execute("select domains.Domain_ID, domains.Domain, domains.Post_Office_ID, domains.Status, domains.Misc from domains where domains.Domain = '" + A[2] + "'", out ob, -1);
break;
}
if (!RS.EOF) {
Out_Data += "error ";
} else {
switch (Whatever) {
case "address_map":
DB.Execute("insert into address_maps (Mail_Box_ID, Email, Status, Misc) Values('" + A[2] + "','" + A[3] + "','" + A[4] + "','" + A[5] + "')", out ob, -1);
break;
case "domain":
DB.Execute(myData.pService.SQL_DOMAIN_CHECK.Replace("%1", A[2]).Replace("%2", A[3]).Replace("%3", A[4]).Replace("%4", A[5]), out ob, -1);
break;
}
Out_Data += "good ";
Send(Out_Data + Environment.NewLine);
}
Last edited by transio; Jun 11th, 2003 at 05:22 PM.
- Steve
"I'm glad I wore these pants."
-
Jun 11th, 2003, 05:21 PM
#3
Lively Member
Better yet, try something like this:
Code:
switch (Whatever) {
case "address_map":
selectCmd = myData.pService.SQL_ADDRESS_MAP_CHECK.Replace("%1", A[1]);
insertCmd = "insert into address_maps (Mail_Box_ID, Email, Status, Misc) Values('" + A[2] + "','" + A[3] + "','" + A[4] + "','" + A[5] + "')";
break;
case "domain":
selectCmd = "select domains.Domain_ID, domains.Domain, domains.Post_Office_ID, domains.Status, domains.Misc from domains where domains.Domain = '" + A[2] + "'";
insertCmd = myData.pService.SQL_DOMAIN_CHECK.Replace("%1", A[2]).Replace("%2", A[3]).Replace("%3", A[4]).Replace("%4", A[5]);
break;
}
RS = DB.Execute(selectCmd, out ob, -1);
if (!RS.EOF) {
Out_Data += "error ";
} else {
DB.Execute(selectCmd, out ob, -1);
Out_Data += "good ";
}
Send(Out_Data + Environment.NewLine);
- Steve
"I'm glad I wore these pants."
-
Jun 11th, 2003, 06:41 PM
#4
Thread Starter
Lively Member
Very cool, I like the second method, both are better though then mine. Thanks transio.
Thanks a lot,
Mitchel
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|