From: Peter M. <P.m...@de...> - 2004-03-18 11:36:19
|
.> I have had difficulties with large inserts (> 16000). Do you experience .any? .No, but i have tested large inserts ( using AS3AP benchmark, up to .500000 inserts ) but no using DataSets, can you post a code snippet ??, .i can try to a test if needed. This is part of a routine to store any dataset into the database, so I create the SQL for the table as well (although the code is not yet complete). OK, here it is: string TableName = "TEST1"; string Message = String.Empty; DataSet ds = new DataSet("ds"+ TableName); DataTable dt; dt = new DataTable(TableName); dt.Columns.Add("TSTAMP",typeof(String)); dt.Columns.Add("ID",typeof(Int32)); dt.Columns.Add("MSG",typeof(String)); ds.Tables.Add(dt); // ExecuteNonQuery("drop table " + TableName + ";"); bool first1 = true; bool HasID = false; string cmd = "create table " + TableName + "("; for(int i=0; i < ds.Tables[0].Columns.Count; i++) { DataColumn dc = ds.Tables[0].Columns[i]; if( first1 ) first1 = false; else { cmd += ","; } System.Text.StringBuilder fc = new System.Text.StringBuilder(dc.ColumnName.ToUpper()); if( fc.Length < 1 ) { Message = "Kolom zonder naam gevonden"; return ; } if( !System.Char.IsLetter(fc[0]) ) fc = new System.Text.StringBuilder("N"+ fc) ; for( int k =0 ; k < fc.Length;k++) { if( System.Char.IsLetterOrDigit(fc[k]) ) continue; fc[k] = '_'; // maak van de rest een underscore } if( fc.ToString() == "ID" ) { HasID = true; dc.AllowDBNull = false; } fc.Append(" "); if( dc.DataType == typeof(System.DateTime)) fc.Append( "TIMESTAMP"); else if( dc.DataType == typeof(System.Int16)) fc.Append("INTEGER"); else if( dc.DataType == typeof(System.Int32)) fc.Append( "INTEGER"); else if( dc.DataType == typeof(System.Double)) fc.Append("DOUBLE PRECISION"); else if( dc.DataType == typeof(System.Object)) fc.Append( "BLOB"); else { fc.Append("VARCHAR(30)"); } if( ! dc.AllowDBNull ) fc.Append( " not null"); cmd += fc; } if( !HasID ) { cmd += ",ID INTEGER NOT NULL"; } cmd += ");"; db.ExecuteNonQuery(cmd); // create primary keys: todo gebruik key van tabel cmd = @"alter table " + TableName + " add constraint PK1 primary key (ID);"; db.ExecuteNonQuery(cmd); FbDataAdapter mDataAdapter = new FbDataAdapter(); mDataAdapter.SelectCommand = new FbCommand("SELECT * FROM " + TableName + ";", db.myConnection,db.txn); FbCommandBuilder cb = new FbCommandBuilder(mDataAdapter); // genereer de insert, etc DataSet nds = new DataSet("ds" + TableName); mDataAdapter.Fill(nds, TableName); nds.Tables[0].TableName = TableName; int id = 1; int c = 0; for(int j=0; j < 50000; j++){ DataRow dr = ds.Tables[0].NewRow(); dr["ID"] = id++; dr["TSTAMP"] = System.DateTime.Now.ToShortTimeString(); dr["MSG"] = System.DateTime.Now.ToShortDateString(); ds.Tables[0].Rows.Add(dr); } mDataAdapter.Update(ds,TableName); // do it db.Commit(); // retaining } This results in: An unhandled exception of type 'FirebirdSql.Data.Firebird.FbException' occurred in system.data.dll Additional information: invalid request handle If j is run up to 10000, it will execute fine. Hope you can find anything. Peter |