我在 SQLBase 中选择了一些值,我想将它们导入 MySQL。但问题仍然存在,如我的标题所示。
场景是这样的:我只需要在 SQLBase 中选择一些字段及其值,然后将它们插入 MySQL。如何将sqlbase数据导入mysql?
这是我的代码:
Dim conn As New SQLBaseConnection("DB=Source;SERVER=SERVER1;UID=SYSADM;PWD=password;INI=C:\Program Files\Gupta\SQLBase901\sql.ini")
Try
conn.Open()
Dim adaptor As New SQLBaseDataAdapter
Dim ds As New DataSet
adaptor.SelectCommand() = New SQLBaseCommand("SELECT * FROM PERSON WHERE TYPE='E'", conn)
ds = New DataSet()
adaptor.Fill(ds, "ID")
Dim datTable As DataTable = ds.Tables("ID")
Dim id, type, name, proximity, department, section, costCenter, lastName, firstName, midName, company As String
If datTable.Rows.Count > 0 Then
For i As Integer = 0 To datTable.Rows.Count - 1
id = datTable.Rows(i)(0)
type = datTable.Rows(i)(1)
name = datTable.Rows(i)(8)
proximity = datTable.Rows(i)(33)
department = datTable.Rows(i)(51)
section = datTable.Rows(i)(58)
costCenter = datTable.Rows(i)(55)
firstName = datTable.Rows(i)(3)
midName = datTable.Rows(i)(4)
lastName = datTable.Rows(i)(5)
company = datTable.Rows(i)(50)
Insert201(id, type, name, proximity, department, section, costCenter, lastName, firstName, midName, company, conn)
i += 1
Application.DoEvents()
Next
End If
conn.Close()
Catch ex As Exception
'TextBox1.Text = ex.Message
End Try
然后在另一个子过程中我称之为:
Public Sub Insert201(ByVal id, ByVal type, ByVal name, ByVal proximity, ByVal department, ByVal section, ByVal costCenter, ByVal lastName, ByVal firstName, ByVal midName, ByVal company, ByVal conn)
Dim Query As String
Query = "INSERT INTO tbl_201 VALUES ('" + id + "','" + type + "','" + name + "','" + proximity + "','" + department + "', '" + section + "', '" + costCenter + "','" + lastName + "', '" + firstName + "', '" + midName + "','" + company + "')"
Try
conn.Open()
Dim sql As MySqlCommand = New MySqlCommand(Query, conn)
sql.ExecuteNonQuery()
'MsgBox("Record is Successfully Inserted")
conn.Close()
Catch ex As Exception
conn.Close()
MsgBox("Record is not Inserted" + ex.Message)
End Try
End Sub