我有問題,當我嘗試選擇加入與附加數據庫命令從不同的SQLite數據庫表和把值到datagridview的附加2 SQLite數據庫,然後選擇表
他們得到許多錯誤如:數據庫無法打開,ExuteNonQuery錯誤,無法打開連接,無法打開數據庫。
pathinfo2作爲我的主數據庫和pathinfo1我的DB2
這是我的代碼:
Sub slc_smscontact()
Dim fc1 As String = "Data Source=" + pathinfo2.Text + ";Version=3;"
Dim SQL As String = "ATTACH '" + pathinfo1.Text + "' AS db2"
Dim com As New SQLiteCommand(SQL)
Dim connection As SQLiteConnection = New SQLiteConnection(fc1)
'connection.ConnectionString = fc1
com.Connection = connection
connection.Open()
Dim retval As Integer = 0
Try
retval = com.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("An error occurred, your attach databases was not completed.")
Finally
com.Dispose()
End Try
SQL = "select distinct a.data1 no_telp, b.data1 nama, db2.sms.address, db2.sms.body, db2.sms.date, db2.sms.date_sent, db2.sms.Thread_id from (select raw_contact_id,data1 from data where mimetype_id = 5) as a, (select raw_contact_id,data1 from data where mimetype_id = 7) as b where a.raw_contact_id = b.raw_contact_id INNER JOIN db2.sms ON data.no_telp = db2.sms.address;"
com = New SQLiteCommand(SQL)
com.Connection = connection
'retval = 0
Try
Dim ds3 As New DataSet()
Dim da3 As New SQLiteDataAdapter(com)
da3.Fill(ds3)
grid3.DataSource = ds3.Tables(0).DefaultView
'retval = com.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("An error occurred, your select was not completed.")
Finally
'com.Dispose()
connection.Close()
End Try
End Sub
有任何人知道如何解決它?
如果回答了這個問題,請點擊對號,以便將此帖子移出未回覆列表。 – Plutonix