Click here to Skip to main content
16,011,626 members
Home / Discussions / C#
   

C#

 
GeneralRe: Query: The | Operator Pin
Tristan Rhodes30-Nov-03 7:06
Tristan Rhodes30-Nov-03 7:06 
QuestionHow to convert "string" type to "Shortcut" type ? Pin
god4k30-Nov-03 3:35
god4k30-Nov-03 3:35 
AnswerRe: How to convert "string" type to "Shortcut" type ? Pin
Alex Korchemniy30-Nov-03 14:23
Alex Korchemniy30-Nov-03 14:23 
AnswerRe: How to convert "string" type to "Shortcut" type ? Pin
J. Dunlap30-Nov-03 16:42
J. Dunlap30-Nov-03 16:42 
GeneralRounding the Time Pin
Anonymous30-Nov-03 0:29
Anonymous30-Nov-03 0:29 
GeneralRe: Rounding the Time Pin
Alex Korchemniy30-Nov-03 14:17
Alex Korchemniy30-Nov-03 14:17 
Generalselect, insert, update, del with ADO.net with C# Pin
Azel Low29-Nov-03 23:07
Azel Low29-Nov-03 23:07 
GeneralRe: select, insert, update, del with ADO.net with C# Pin
Uwe Keim30-Nov-03 3:14
sitebuilderUwe Keim30-Nov-03 3:14 
I use something similar to this for INSERT an new record:
OleDbConnection conn = new OleDbConnection( DB_STR );
OleDbDataAdapter da = new OleDbDataAdapter( "SELECT TOP 1 * FROM Guestbook", conn );
OleDbCommandBuilder cb = new OleDbCommandBuilder( da );
cb.QuotePrefix = "[";
cb.QuoteSuffix = "]";
  
DataSet ds = new DataSet();
da.Fill( ds );
  
DataTable table = ds.Tables[0];
DataRow row = table.NewRow();
  
row["Date"] = DateTime.Now;
row["Name"] = name;
row["EMail"] = email;
row["Text"] = text;
table.Rows.Add( row );
  
da.Update( ds );
  
conn.Close();


And for INSERT or UPDATE:
OleDbConnection conn = new OleDbConnection( DB_STR );
// do your query for a specific recordset.
// if it returns none, you must create a new, otherwise modify the existing.
OleDbDataAdapter da = new OleDbDataAdapter( "SELECT TOP 1 * FROM Guestbook WHERE ID="+ID, conn );
OleDbCommandBuilder cb = new OleDbCommandBuilder( da );
cb.QuotePrefix = "[";
cb.QuoteSuffix = "]";
    
DataSet ds = new DataSet();
da.Fill( ds );
    
DataTable table = ds.Tables[0];
    
// create new.
if ( table.Rows.Count==0 )
{
    DataRow row = table.NewRow();

    row["Date"] = DateTime.Now;
    row["Name"] = name;
    row["EMail"] = email;
    row["Text"] = text;
    
    table.Rows.Add( row );
}
// modify existing.
else
{
    DataRow row = table.Rows[0];
    
    row["Date"] = DateTime.Now;
    row["Name"] = name;
    row["EMail"] = email;
    row["Text"] = text;
}
    
da.Update( ds );
    
conn.Close();


For the SELECT and DELETE I just use single-statement SQL-queries, which I format with string.Format().

--
- Free Windows-based CMS: www.zeta-software.de/enu/producer/freeware/download.html
- See me: www.magerquark.de


GeneralRe: select, insert, update, del with ADO.net with C# Pin
Azel Low1-Dec-03 0:51
Azel Low1-Dec-03 0:51 
QuestionHow to customize http connection timeout? Pin
shooterlily29-Nov-03 19:51
shooterlily29-Nov-03 19:51 
AnswerRe: How to customize http connection timeout? Pin
Heath Stewart1-Dec-03 2:07
protectorHeath Stewart1-Dec-03 2:07 
GeneralRe: How to customize http connection timeout? Pin
shooterlily4-Dec-03 15:38
shooterlily4-Dec-03 15:38 
GeneralRe: How to customize http connection timeout? Pin
shooterlily4-Dec-03 18:11
shooterlily4-Dec-03 18:11 
GeneralRe: How to customize http connection timeout? Pin
Heath Stewart4-Dec-03 18:55
protectorHeath Stewart4-Dec-03 18:55 
GeneralRe: How to customize http connection timeout? Pin
shooterlily7-Dec-03 18:56
shooterlily7-Dec-03 18:56 
GeneralWriting to a cd Pin
Oscar Dog29-Nov-03 17:46
Oscar Dog29-Nov-03 17:46 
GeneralRe: Writing to a cd Pin
Heath Stewart1-Dec-03 2:11
protectorHeath Stewart1-Dec-03 2:11 
GeneralRe: Writing to a cd Pin
Oscar Dog2-Dec-03 17:24
Oscar Dog2-Dec-03 17:24 
GeneralService doesn't show in Services. Pin
IrishSonic29-Nov-03 13:29
IrishSonic29-Nov-03 13:29 
GeneralRe: Service doesn't show in Services. Pin
Colin Angus Mackay29-Nov-03 13:49
Colin Angus Mackay29-Nov-03 13:49 
GeneralPiecing 200 jpgs into a single jpg Pin
ke5in29-Nov-03 6:15
ke5in29-Nov-03 6:15 
GeneralRe: Piecing 200 jpgs into a single jpg Pin
Christian Graus30-Nov-03 10:48
protectorChristian Graus30-Nov-03 10:48 
GeneralRe: Piecing 200 jpgs into a single jpg Pin
ke5in1-Dec-03 5:47
ke5in1-Dec-03 5:47 
GeneralCalling One Form in a Project from Another Pin
Chuck Schmidt29-Nov-03 2:37
Chuck Schmidt29-Nov-03 2:37 
GeneralRe: Calling One Form in a Project from Another Pin
Psi5729-Nov-03 5:26
Psi5729-Nov-03 5:26 

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.