arraylist和sqlite表之间的数据交换 [英] Data exchange between arraylist and sqlite table

查看:95
本文介绍了arraylist和sqlite表之间的数据交换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

我开发了一个小的Windows窗体应用程序,它使用arraylist作为数据源.现在,我要向前迈出一步.是否有可能将arraylist中的数据逐行写入sqlite表中.另一种方法是从sqlite表读取数据并将其写入 也可以逐行放入arraylist中.我找不到有关这种数据交换方式的任何信息.

I developed a small windows forms app using an arraylist as data source. Now I want to take a step forward. Is it possible to write data row by row from the arraylist into sqlite tables. The other way around reading data from sqlite tables and writing them into the arraylist row by row would be nice, too.I do not find any information about this way of data exchange.

有人可以为我分配一个代码示例吗?我也对处理此问题的在线教程和书籍感兴趣.也许有人为我提供了一些链接.

Can someone allocate a code example for me? I am also interested in online tutorials and books handling this problem. Maybe someone has a few links for me.

推荐答案

您将使用由ADO.NET数据读取器加载并从方法中返回的对象的集合.读取T-SQL查询的结果.

You would be using a collection of objects that were loaded by an ADO.NET Data reader and returned out of a method that was reading the results of a T-SQL query.

顺序位置索引用于寻址返回结果集中的一列.

The ordinal position index is used to address a column in the returned resultset.

http://zetcode.com/db/sqlitecsharp/read/

在使用数据读取器时,可以在上面的示例中使用列名而不是顺序位置.因此,您可以搜索Google或Bing并使用列名查找ADO.NET Datareader示例.

You can use the columnname in the above example instead of the ordinal position when using a datareader. So you can seach Google or Bing and find a ADO.NET Datareader example using columnname.

您将使用列表< Of T>您在datareader循环中的位置,创建一个名为Payroll的新对象,在循环中填充该对象,并将Payroll对象加载到List< Of Payroll>中.

You'll be using a List <Of T> where is you are in the datareader loop, you create a new object call it Payroll, you populate the object in the loop and load the Payroll object into the List <Of Payroll>.

薪资对象可以使用使用自动属性的对象.

The Payroll object can use an object that is using auto-properties.

https://msdn.microsoft.com/en-us/library/dd293589.aspx?f = 255& MSPPError = -2147217396

https://www.dotnetperls.com/property-vbnet

然后,您可以在foreach循环中使用对象集合,并基于对象及其数据创建T-SQL语句,从而在数据库表中插入,更新或删除数据.

Then you can use the collection of objects in a foreach loop and make T-SQL statements based on an object and its data that way to do insert, update or delete data in a database table.

所以弄清楚如何使用List< of T>.

So figure out how to use a List<of T>.


这篇关于arraylist和sqlite表之间的数据交换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆