欧美久久天天综合香蕉伊,h片在线免费观看,九九欧美,欧美1区2区3区,日本在线不卡一区,国产视频久久久,91久久久久久久

2023信創(chuàng)獨(dú)角獸企業(yè)100強(qiáng)
全世界各行各業(yè)聯(lián)合起來,internet一定要實(shí)現(xiàn)!

設(shè)置對VB數(shù)據(jù)庫連接的動(dòng)態(tài)路徑

2004-02-11 eNet&Ciweek

  筆者的解決方法是利用app.path 來解決這個(gè)問題。

  一、用data控件進(jìn)行數(shù)據(jù)庫鏈接,可以這樣:

  在form_load()過程中放入:

  private form_load()

  Dim str As String '定義

  str = App.Path

  If Right(str, 1) <> "" Then

  str = str + ""

  End If

  data1.databasename=str & "數(shù)據(jù)庫名"

  data1.recordsource="數(shù)據(jù)表名"

  data1.refresh

  sub end

  這幾句話的意為,打開當(dāng)前程序運(yùn)行的目錄下的數(shù)據(jù)庫。

  你只要保證你的數(shù)據(jù)庫在你程序所在的目錄之下就行了。

  

  二、利用adodc(ADO Data Control)進(jìn)行數(shù)據(jù)庫鏈接:

  private form_load ()

  Dim str As String '定義

  str = App.Path

  If Right(str, 1) <> "" Then

  str = str + ""

  End If

  str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & str & " sl.mdb"

  Adodc1.ConnectionString = str

  Adodc1.CommandType = adCmdText

  Adodc1.RecordSource = "select * from table3"

  Adodc1.Refresh

  end sub

  

  三、利用DataEnvironment進(jìn)行數(shù)據(jù)庫鏈接

  可在過程中放入:

  On Error Resume Next

  If DataEnvironment1.rsCommand1.State <> adStateClosed Then

  DataEnvironment1.rsCommand1.Close '如果打開,則關(guān)閉

  End If

  'i = InputBox("請輸入友人編號:", "輸入")

  'If i = "" Then Exit Sub

  DataEnvironment1.Connection1.Open App.Path & "userdatabase sl.mdb"

  DataEnvironment1.rsCommand1.Open "select * from table3 where 編號='" & i & "'"

  'Set DataReport2.DataSource = DataEnvironment1

  'DataReport2.DataMember = "command1"

  'DataReport2.show

  end sub

  

  四、利用ADO(ActiveX Data Objects)進(jìn)行編程:

  建立連接:

  dim conn as new adodb.connection

  dim rs as new adodb.recordset

  dim str

  str = App.Path

  If Right(str, 1) <> "" Then

  str = str + ""

  End If

  str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & str & " sl.mdb"

  conn.open str

  rs.cursorlocation=aduseclient

  rs.open "數(shù)據(jù)表名",conn,adopenkeyset.adlockpessimistic

  用完之后關(guān)閉數(shù)據(jù)庫:

  conn.close

  set conn=nothing

  (完)

相關(guān)頻道: eNews

您對本文或本站有任何意見,請?jiān)谙路教峤唬x謝!

投稿信箱:tougao@enet16.com