Click here to Skip to main content
15,898,794 members
Home / Discussions / C#
   

C#

 
AnswerRe: ctrl+c and ctrl+v not working in TextBox Pin
pratap bhargava25-Jun-10 18:07
pratap bhargava25-Jun-10 18:07 
QuestionClass inheritance Pin
you3030-Sep-06 0:47
you3030-Sep-06 0:47 
AnswerRe: Class inheritance Pin
Guffa30-Sep-06 3:49
Guffa30-Sep-06 3:49 
Questionchat application Pin
rcwoods29-Sep-06 23:57
rcwoods29-Sep-06 23:57 
AnswerRe: chat application Pin
umseker30-Sep-06 4:23
umseker30-Sep-06 4:23 
Questioncreating insert statement using arrays Pin
DownBySpj29-Sep-06 23:21
DownBySpj29-Sep-06 23:21 
AnswerRe: creating insert statement using arrays Pin
Guffa29-Sep-06 23:33
Guffa29-Sep-06 23:33 
AnswerRe: creating insert statement using arrays Pin
zhengdong jin29-Sep-06 23:56
zhengdong jin29-Sep-06 23:56 
public string[] GenInsertCmd(DataTable table)
{
string inscmd = "insert into " + table.TableName.Trim().ToLower() + " (";

foreach(DataColumn col in table.Columns)
{
inscmd += col.ColumnName + ",";
}

inscmd = inscmd.Substring(0,inscmd.Length - 1) + ") values (";

string[] sqlcmd = new string[table.Rows.Count];
int i = 0;

foreach(DataRow row in table.Rows)
{
sqlcmd[i] = "";

foreach(DataColumn col in table.Columns)
{
switch (col.DataType.Name.Trim().ToLower())
{
case "string":
try
{
sqlcmd[i] += "'" + ((string)row[col]).Trim().Replace("'","\"") + "',";
}
catch
{
sqlcmd[i] += "null,";
}
break;
case "datetime":
try
{
sqlcmd[i] += "'" + ((DateTime)row[col]).ToString("yyyy-MM-dd hh:mm:ss.sss") + "',";
}
catch
{
sqlcmd[i] += "null,";
}
break;
case "boolean":
try
{
sqlcmd[i] += ((bool)row[col] == true ? "1," : "0,");
}
catch
{
sqlcmd[i] += "null,";
}
break;
case "byte[]":
sqlcmd[i] += "null" + ",";
break;
default:
if (row[col].ToString().Trim() == "")
sqlcmd[i] += "null,";
else
sqlcmd[i] += row[col].ToString().Trim() + ",";
break;
}
}
sqlcmd[i] = inscmd + sqlcmd[i].Substring(0,sqlcmd[i].Length - 1) + ")";

i += 1;
}

return sqlcmd;
}

GeneralRe: creating insert statement using arrays Pin
Guffa30-Sep-06 1:04
Guffa30-Sep-06 1:04 
Questionsimple picture box question Pin
rzvme29-Sep-06 22:26
rzvme29-Sep-06 22:26 
AnswerRe: simple picture box question Pin
Stefan Troschuetz29-Sep-06 22:34
Stefan Troschuetz29-Sep-06 22:34 
GeneralRe: simple picture box question Pin
rzvme29-Sep-06 22:57
rzvme29-Sep-06 22:57 
GeneralRe: simple picture box question Pin
Stefan Troschuetz29-Sep-06 23:44
Stefan Troschuetz29-Sep-06 23:44 
QuestionRe: simple picture box question Pin
rzvme30-Sep-06 3:17
rzvme30-Sep-06 3:17 
Questionform variables Pin
milleusi29-Sep-06 22:15
milleusi29-Sep-06 22:15 
AnswerRe: form variables Pin
Stefan Troschuetz29-Sep-06 22:37
Stefan Troschuetz29-Sep-06 22:37 
QuestionThreading Pin
clint198229-Sep-06 21:44
clint198229-Sep-06 21:44 
AnswerRe: Threading Pin
geo_m29-Sep-06 21:48
geo_m29-Sep-06 21:48 
AnswerRe: Threading Pin
Christopher Duncan30-Sep-06 1:32
Christopher Duncan30-Sep-06 1:32 
QuestionSFTP client and server dll for C# windows form Pin
Pavan Josh29-Sep-06 21:17
Pavan Josh29-Sep-06 21:17 
QuestionMobile API in C# Pin
yousafzai29-Sep-06 20:28
yousafzai29-Sep-06 20:28 
Questionproblem in querying database Pin
DownBySpj29-Sep-06 19:45
DownBySpj29-Sep-06 19:45 
AnswerRe: problem in querying database Pin
Nafiseh Salmani29-Sep-06 19:56
Nafiseh Salmani29-Sep-06 19:56 
GeneralRe: problem in querying database Pin
DownBySpj29-Sep-06 20:52
DownBySpj29-Sep-06 20:52 
AnswerRe: problem in querying database Pin
jeyapandian29-Sep-06 20:49
jeyapandian29-Sep-06 20:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.