Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the use of VB6.0 datatable?

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the use of VB6.0 datatable, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

In VB6.0, ADO is widely used in database programming. In the new vb.net, although it can also be used to query the database, but in the binding to the new datagrid, it can not be used as before: "datagrid1.datasoure=rs", but requires some transformation. Because the new datagrid.datasoure corresponds to VB6.0 datatable or dataset, not the original Recordset. So, in use, convert Recordset to VB6.0 datatable or dataset. Let's take VB6.0 datatable as an example:

Function RecordsetToDataTable (ByVal adoRS As ADODB.Recordset

ByVal strTable As String)

AdoRS.MoveFirst ()

Dim dt As DataTable

Dt = New DataTable (strTable)

Dim i As Integer

Dim strcolname As String

Dim t As Type

Dim dr As DataRow

For I = 0 To adoRS.Fields.Count-1

Strcolname = adoRS.Fields (I) .Name

T = adoRS.Fields (I) .Value.GetType ()

Dt.Columns.Add (strcolname, t)

Next

While (Not adoRS.EOF)

Dr = dt.NewRow ()

For I = 0 To adoRS.Fields.Count-1

Dr (I) = adoRS.Fields (I) .Value

Next

Dt.Rows.Add (dr)

AdoRS.MoveNext ()

End While

Return dt

End Function

The above function is to convert Recordset to DataTable. What we need to do is to add the transformation to ADO in the load of the window and then refer to it.

Dim dts As DataTable dts = RecordsetToDataTable (rsuser, "login") 'where rsuser is ado.Recordset, and "login" is the table name DataGrid1.DataSource = dts.DefaultView. Thank you for reading this article carefully. I hope the article "what's the use of VB6.0 datatable" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report