Click here to Skip to main content
15,914,312 members
Home / Discussions / C#
   

C#

 
AnswerRe: Trim a part of string away Pin
Dave Kreskowiak30-Aug-06 5:43
mveDave Kreskowiak30-Aug-06 5:43 
QuestionSerialization of a datatable using FileMode.Append Pin
John Baird30-Aug-06 3:13
John Baird30-Aug-06 3:13 
AnswerRe: Serialization of a datatable using FileMode.Append Pin
Robert Rohde30-Aug-06 5:00
Robert Rohde30-Aug-06 5:00 
GeneralRe: Serialization of a datatable using FileMode.Append Pin
John Baird30-Aug-06 9:12
John Baird30-Aug-06 9:12 
Questioncrestal report Pin
TAREQ F ABUZUHRI30-Aug-06 3:09
TAREQ F ABUZUHRI30-Aug-06 3:09 
Questionusing an eventhandler for a serialport Pin
Yustme30-Aug-06 2:52
Yustme30-Aug-06 2:52 
QuestionHow to insert data in a sql database from datagrid column Pin
choopie30-Aug-06 2:41
choopie30-Aug-06 2:41 
AnswerRe: How to insert data in a sql database from datagrid column Pin
mikone30-Aug-06 2:58
mikone30-Aug-06 2:58 
you could do it like this or by using a sql/odbc/oledb datadapter (e.g. system.data.oledb.oledbdataadapter) and set it up. this is a bit more complicated and i used it only once so you should go and google for it. the msdn has some nice explaination about how to use this thing. if you want to do it by yourself, you will have to have an array (or list or anything else) containg the values and the fieldname (a 2-dimensional array would do the job Wink | ;)

if you got a table consisting of 3 columns (e.g. id, name, postdate) you would need an array like this:
data[0,0] = "id";<br />
data[0,1] = 0;<br />
data[1,0] = "name";<br />
data[1,1] = "myname";<br />
data[2,0] = "postdate";<br />
data[2,1] = "2006-05-02";<br />
(alternatively you could use 2 single array, one holding the column names and the other one holding the column values)

it would be easy to generate the statement then - it could look like

string sqlquery = "INSERT INTO tablename (";<br />
string comma = "";<br />
<br />
for (int i = 0; i < data.GetLength(0)-1; i++)<br />
{<br />
   if (i > 0)<br />
      comma = ","<br />
   sqlquery = sqlquery + comma + data[i,0];<br />
}<br />
<br />
sqlquery = sqlquery + ") VALUES (";<br />
<br />
for (int i = 0; i < data.GetLength(0)-1; i++)<br />
{<br />
   if (i > 0)<br />
      comma = ","<br />
   sqlquery = sqlquery + comma + "'" + data[i,1] + "'";<br />
}<br />
<br />
sqlquery = sqlquery + ");";<br />


this code would produce a query like
<br />
INSERT INTO tablename (id,name,postdate) VALUES ('0','myname','2006-05-02');<br />


since this can be a lot of work you should make yourself familiar with the dataadapters Smile | :)
GeneralRe: How to insert data in a sql database from datagrid column Pin
choopie30-Aug-06 3:12
choopie30-Aug-06 3:12 
GeneralRe: How to insert data in a sql database from datagrid column Pin
Tom Wright30-Aug-06 4:18
Tom Wright30-Aug-06 4:18 
QuestionGeneric Classes and Pointer to one of its Typeparameters [modified] Pin
mikone30-Aug-06 2:30
mikone30-Aug-06 2:30 
QuestionHow Microsoft does it? Pin
jayvardhanpatil30-Aug-06 0:36
jayvardhanpatil30-Aug-06 0:36 
QuestionGetting Icon information from which an application is run Pin
Sgg24530-Aug-06 0:10
Sgg24530-Aug-06 0:10 
AnswerRe: Getting Icon information from which an application is run Pin
leppie30-Aug-06 0:59
leppie30-Aug-06 0:59 
QuestionIs it possible to serialise this in C#? [modified] Pin
stevenykl29-Aug-06 23:46
stevenykl29-Aug-06 23:46 
AnswerRe: Is it possible to serialise this in C#? Pin
Andrei Ungureanu29-Aug-06 23:56
Andrei Ungureanu29-Aug-06 23:56 
GeneralRe: Is it possible to serialise this in C#? Pin
stevenykl30-Aug-06 0:11
stevenykl30-Aug-06 0:11 
QuestionRegarting tree view Drag drop Pin
chandler8329-Aug-06 22:32
chandler8329-Aug-06 22:32 
QuestionDrawing Pin
Vsree29-Aug-06 22:03
Vsree29-Aug-06 22:03 
AnswerRe: Drawing Pin
Andrei Ungureanu29-Aug-06 23:39
Andrei Ungureanu29-Aug-06 23:39 
GeneralRe: Drawing Pin
Vsree30-Aug-06 0:06
Vsree30-Aug-06 0:06 
GeneralRe: Drawing Pin
Andrei Ungureanu30-Aug-06 0:22
Andrei Ungureanu30-Aug-06 0:22 
GeneralRe: Drawing Pin
Robert Rohde30-Aug-06 5:05
Robert Rohde30-Aug-06 5:05 
QuestionWM_SETFOCUS? Pin
wbjohnson29-Aug-06 22:01
wbjohnson29-Aug-06 22:01 
AnswerRe: WM_SETFOCUS? Pin
mav.northwind30-Aug-06 9:47
mav.northwind30-Aug-06 9:47 

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.