O
OldEnough
New to SQL Server (running SQL Server Express 2005) would like to pull data
from server table to local table. Databases are not linked.
latest attempt below
GetSQLServerName() and GetMainSQLdb() functions identify server and
database from a config file
Dim DB As DAO.Database
Set DB = CurrentDb
Dim oCmd As Command
Dim Mystr as string
Mystr = CurrentDb.Name
Dim oRS As New adodb.Recordset
Dim cn As New adodb.Connection
Dim strSQl As String
Dim connectStr As String
connectStr = "Provider=SQLNCLI10;Server=" & GetSQLServerName() &
";Database=" & GetMainSQLdb() & ";Trusted_Connection=yes;"
cn.Open connectStr
strSQl = "INSERT INTO tblEmployees IN '" & Mystr & "' SELECT
tblEmployees.* FROM tblEmployees;"
Set oCmd = New Command
With oCmd
.CommandText = strSQl
.CommandType = adCmdText
.ActiveConnection = cn
Set oRS = .Execute
End With
With access provider and connection string - between two access databases
this works. With SQL provider it gives an "Error near keyword IN'
All suggestions will be gratefully accepted.
from server table to local table. Databases are not linked.
latest attempt below
GetSQLServerName() and GetMainSQLdb() functions identify server and
database from a config file
Dim DB As DAO.Database
Set DB = CurrentDb
Dim oCmd As Command
Dim Mystr as string
Mystr = CurrentDb.Name
Dim oRS As New adodb.Recordset
Dim cn As New adodb.Connection
Dim strSQl As String
Dim connectStr As String
connectStr = "Provider=SQLNCLI10;Server=" & GetSQLServerName() &
";Database=" & GetMainSQLdb() & ";Trusted_Connection=yes;"
cn.Open connectStr
strSQl = "INSERT INTO tblEmployees IN '" & Mystr & "' SELECT
tblEmployees.* FROM tblEmployees;"
Set oCmd = New Command
With oCmd
.CommandText = strSQl
.CommandType = adCmdText
.ActiveConnection = cn
Set oRS = .Execute
End With
With access provider and connection string - between two access databases
this works. With SQL provider it gives an "Error near keyword IN'
All suggestions will be gratefully accepted.