Dim conn As MySql.Data.MySqlClient.MySqlConnection
Dim cmd As MySql.Data.MySqlClient.MySqlCommand
Dim connStr As String = "server=****; port=****; user id=****; password=****; database=****;CharSet=utf8" '设置你的数据库连接字符串
conn = New MySql.Data.MySqlClient.MySqlConnection(connStr)
conn.Open
Dim mda As New MySql.Data.MySqlClient.MySQLDataAdapter("select * fro m ipos_sptpk" , conn) '这里可以设置你的查询语句
Dim ds As New System.Data.DataSet()
mda.Fill(ds, "TableTemp") 'MySQLDataAdapter方法把数据放到一个新建的临时表里,这个临时表名可自定义,我这里写TableTemp
Dim Vals As List(of String())
Vals = ds.DataTables("TableTemp").GetValues("spdm|pic_name")
For i As Integer = 0 To Vals.Count - 1
Dim dr As DataRow = DataTables("SPTPB").AddNew()
dr("spdm") = Vals(i)(0)
此主题相关图片如下:30.png
dr("pic_name") = Vals(i)(1)
Next
conn.close
[此贴子已经被作者于2020/6/5 23:51:28编辑过]