dataadapter

Using OleDbDataAdapter to update a DataTable C#

我只是一个虾纸丫 提交于 2019-12-17 19:56:18
问题 I have been trying to use OleDbDataAdapter to update a DataTable but got confused about the commands. Since I sometimes get info from diffrent tables I can't use a CommandBuilder. So I have tried to create the commands on my on but found it hard with the parameters. DataTable.GetChanges returns rows that needs to use an INSERT or an UPDATE command - I guess I can't distinct between them. I need you to complete the following: DataTable dt = new DataTable(); OleDbDataAdapter da = new

Error from OdbcDataAdapter.Fill

跟風遠走 提交于 2019-12-13 03:37:37
问题 I sometimes get two different of error when executing OdbcDataAdapter.Fill(DataTable). Here is the code example: string odbc = "select item, upcno from table"; OdbcCommand cmd = new OdbcCommand(odbc, fconn); OdbcDataAdapter oda = new OdbcDataAdapter(cmd); oda.Fill(dt); System.NullReferenceException: Object reference not set to an instance of an object. System.InvalidOperationException: No data exists for the row/column. Does anyone have clue to resolve this problem? 回答1: Not sure where you

Getting error while inserting datatables records in my database table

笑着哭i 提交于 2019-12-13 02:18:40
问题 I am pretty new with ado.net and currently working with inserting datatable records to my database tables. I have 1 Excel file which contains some data and from this Excel file I am creating a dataset which contains lots of datatables. In this dataset I have 2 datatables in the form of this: Datatable 0 with records: Category ParentCategory Description Electronics jhdkhsd Sports kjshfhs Datatable 1 with records: SubCategory Subcategory ParentCategory Description Mobile Electronics weprwp Tv

.NET DataSet.HasChanges is incorrectly false

时光毁灭记忆、已成空白 提交于 2019-12-12 14:16:03
问题 Has anybody come across ds.hasChanges() being false despite that the ds clearly has the changes while you check it at a breakpoint? I've been looking at it for quite a while and I can't see what is wrong... // connectionstring and command has been set DataSet ds = new DataSet(); BindingSource myBindingSource = new BindingSource(); SqlDataAdapter dataAdapter1 = new SqlDataAdapter(); dataAdapter1.Fill(ds, "Data"); myBindingSource.DataSource = ds.Tables["Data"]; // then changes made to the

DataAdapter.Fill() behavior for row deleted at the data source

徘徊边缘 提交于 2019-12-12 12:15:16
问题 I'm using the DataSet / DataTable / DataAdapter architecture to mediate between the database and my model objects, which have their own backing (they aren't backed by a DataRow). I've got a DataAdapter with AcceptChangesDuringFill = False , AcceptChangesDuringUpdate = False , and FillLoadOption = OverwriteChanges . Here's my understanding of the DataAdapter model under these conditions: DataAdapter.Update() DataRowState.Added will result in the InsertCommand firing DataRowState.Modified will

Why it doesn't save changes into datatable from datagridview?

◇◆丶佛笑我妖孽 提交于 2019-12-12 09:54:05
问题 I have binded datagridview with datatable ( Growns ). My main goal is, that user can work with datagridview ( dataGridView1 ), filling and updating data and when button SAVE is clicked, all data would be saved into datatable, because I need it for further work. Everything works fine, exept saving data into datatable . What am I doing wrong? Here is my code: private void Form2_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'tekmovalecDataSet.Odrasli' table.

DataAdapter.UpdateCommand not working c#?

别等时光非礼了梦想. 提交于 2019-12-12 04:58:15
问题 I am using this code to update "SOME" columns in a table in my database. But everytime I try to do so an error is given. No value given for one or more required parameters. con.Open(); SlipDA = new OleDbDataAdapter(); string sqlUpdate = "Update tbl_Slip SET RaiseBasic=@RaiseBasic, OtherDed=@OtherDed, Arrears=@Arrears, Notes=@Notes WHERE SlipNo=@SlipNo"; SlipDA.UpdateCommand = new OleDbCommand(sqlUpdate, con); SlipDA.UpdateCommand.Parameters.AddWithValue("@RaiseBasic", Convert.ToInt32(dRow[4]

Failed to convert parameter value from a DateTime to a Byte[]

被刻印的时光 ゝ 提交于 2019-12-12 02:47:55
问题 I'm getting error converting parameters from DateTime to Byte[]. The idea is to show data between 2 specified dates that are entered via controls and displayed on GridView, and using a stored procedure to access data. I don't understand the error, but I'm guessing that all the data is put in an Array and passed on to stored procedure: string sDateBegin = Request.Form["fromDate"]; DateTime dtDateBegin = Convert.ToDateTime(sDateBegin); SqlParameter prmDateBegin = new SqlParameter("datebegin",

SQLiteDataAdapter converts empty value to 0 - how to prevent that?

牧云@^-^@ 提交于 2019-12-11 20:37:23
问题 Below is a snippet of the code. As you can see, that method returns a table from SQLite database, and adds that table to a DataSet if it doesn't exist yet. SQLiteConnection connection; DataSet Set = new DataSet(); DataTable GetTable(string tableName, string command) { if (!Set.Tables.Contains(tableName)) { var adapter = new SQLiteDataAdapter(command, connection); SQLiteCommandBuilder builder = new SQLiteCommandBuilder(adapter); adapter.FillSchema(Set, SchemaType.Source, tableName); adapter

c# DataSet.Fill dreadful performance issues with Firebird 2.5

假如想象 提交于 2019-12-11 16:09:31
问题 REMARK I completely rewrite the question as while exploring options and getting insights, I realized the origin of my problem was not at all what I thought. I use Firebird as a database engine and the standard .Net provider (v.5.11.0) to fetch data using following code: // myBlob1 is BLOB SUB_TYPE 1 (text field) with some empty, but some // VERY long stuff (xml-content) which exceeds VARCHAR(32765), but I removed // those before performing my tests!!! var tick = Stopwatch.StartNew();