2017-03-07 7 views
0

私は、Microsoft AccessバックエンドをSQL Serverバックエンドに移行するプロジェクトを進めており、顧客はAccessを使用して挿入、更新、および削除を行うフォームを作成することを主張しています。問題は、彼が自分のマシンにSQLデータツールを持ち、他のチーム(データツールなし)がフォームを使用できる必要があるということです。私はこれについて最善の方法は、彼のチームがそれを使用することができ、私のアクセスの知識は非常に限られているフォームに接続するアクセスを介してOleDbの接続を使用することだと思った。私が今までに持っているのは以下のものですOleDbを使用したアクセスフォームからSQL Severに接続

“Driver=SQLOLEDB;Data Source=SomeServer;Initial Catalog=SomeDatabase;Integrated Security=SSPI” 

私は、ユーザーがSQLボックスに信用を持っており、ODBC経由で接続できることを知っています。私たちは、OleDbを動作させるのに問題があるだけです。アクセスフォームにOleDB接続を展開する方法についてのご意見は、大変ご了承ください。

+0

私はあなたの問題を理解していません。 「AccessフォームでOleDB接続を展開する」とはどういう意味ですか?あなたに私たちを示すコードがありますか?何がうまくいかないの? – nicomp

+0

私が持っているコードはすべて私が含まれています。顧客は能力のためにプログラム的な解決策を使用することはできません。私はアクセスに慣れていないし、SQL Serverへのアクセスから接続を確立する方法がある。私はすべての耳にいる。私の問題は、試行したすべてがうまくいかない、またはエラーが発生することです。何かのような接続ファイルや何かを見つけることができません。 –

答えて

1

ここでは、SQL Serverで使用した接続を示します。これは、信頼できる接続またはSQL Server認証を使用してサポートされています。

Call GetConnection(gvstr_SQLServer_Name, gvstr_SQLServer_Database, _ 
     cnConn, adUseServer, False, False) 

    If GetConnection(gvstr_SQLServer_Name, gvstr_SQLServer_Database, _ 
      gv_DBS_SQLServer, adUseServer, True, False) = True Then 
     gvbln_UsingSQLServer = True 
     DoCmd.Hourglass True 
     ReLink_SQLSERVER_Tables 
    Else 
     gvbln_UsingSQLServer = False 
    End If 



Public Function GetConnection(ByVal strDSN As String, _ 
    ByVal strDatabase As String, _ 
    ByRef cnLocal As ADODB.Connection, _ 
    ByVal CursorLoc As CursorLocationEnum, _ 
    ByVal UsePassword As Boolean, _ 
    ByVal blnTrusted As Boolean) As Boolean 

Dim intWaitDuration  As Integer 
Dim strConnectString As String 
Dim strDisplay   As String 

Const CURRENT_METHOD As String = "GetConnection" 
On Error GoTo ERROR_HANDLER 
GetConnection = False 
intWaitDuration = 60  
Retry_Connection: 
If cnLocal Is Nothing Then Set cnLocal = New ADODB.Connection 
If cnLocal.State = adStateOpen Then 
     Write_To_Log "Connection already open -- -will not reopen!!" 
    GetConnection = True 
    GoTo Proc_Exit 
End If 

With cnLocal 
    Debug.Print "Use TRUSTED CONNECTION (ABOVE)" 
    If gvstr_Workstation = "my-pc" Then 
     strConnectString = "Driver={SQL Server};" & _ 
           "Server=" & strDSN & ";" & _ 
           "Database=" & strDatabase & ";" & _ 
           "Trusted_Connection=yes" 
    Else 
     If blnTrusted = True Then 
      strConnectString = "Driver={SQL Server};" & _ 
           "Server=" & strDSN & ";" & _ 
           "Database=" & strDatabase & ";" & _ 
           "Trusted_Connection=yes" 
     Else 
      strConnectString = "Driver={SQL Server};" & _ 
           "Server=" & strDSN & ";" & _ 
           "Database=" & strDatabase & ";" & _ 
           "User Id=Sql_myuid;Password=ppppp" 

      strDisplay = "Driver={SQL Server};" & _ 
           "Server=" & strDSN & ";" & _ 
           "Database=" & strDatabase & ";" & _ 
           "User Id=S*********t;Password=****************" 

     End If 
    End If 
    Write_To_Log "Will use Conn String: " & strDisplay 
    .ConnectionString = strConnectString 
    .CursorLocation = CursorLoc 
    .Open 
End With 
GetConnection = True 
Proc_Exit: 
Exit Function 

ERROR_HANDLER: 
Debug.Print Err.Number & vbCrLf & Err.Description 

Err.Source = "Module_Utilities: GetConnection at Line: " & Erl 
DocAndShowError 
Resume Proc_Exit 
Resume Next 
Resume 
End Function 
+0

これを追加する必要があるのはどこですか?コードで何かを変更する必要がありますか?変数が表示されません。 –

+0

申し訳ありませんが、最初の指示を使用して関数を呼び出すと、TRUSTED CONNECTIONの値が次のようになります。Call GetConnection( "PROD_0001"、 "MySQLDAtabase"、_ cnConn、adUseServer、False、True)これはSQL Server認証のためのものです:Call GetConnection( "PROD_0001"、 "MySQLDAtabase"、_ cnConn、adUseServer、True、False) –

+0

これを今後のアプリケーションに使用します。このインスタンスには、プログラム以外のソリューションが必要です。 –

関連する問題