I am trying to use the SSMA to migrate two Databases from Access 2007 to SQL Server 2014. The SSMA recognizes the Access DB's but the tables and queries show as zero. I have ammended the permissions to allow admin control and these are copies of the original DB's but the tables don't show up. Is there something I could be missing?
I had the same problem, and after some hours looking on this it seems that one property "SSMATableState" on the tables hides them in SSMA.
Probably SSMA added that after being used, I guess...
In Access add a module and this code, run it to remove that:
Sub tabsSSMAfix()
Dim t As TableDef, a, p
Dim db As Database
Set db = CurrentDb
For Each t In db.TableDefs
If (t.Attributes And dbSystemObject)=0 Then
Debug.Print t.Attributes
Debug.Print t.SourceTableName
For Each p In t.Properties
Debug.Print t.Name; " "; p.Name; "="; p
If p.Name = "SSMATableState" Then
t.Properties.Delete "SSMATableState"
End If
Next p
Debug.Print
End If
Next t
End Sub
Had the same problem recently.
Make sure you are using the connection called:
Native OLE DB\Microsoft Office 12.0 Access Database Engine OLE DB Provider.
You know you are using the right provider when you can preview the data.
Related
I have a MS Access application that has been in use for at least 10 years. Recently I moved my work to a new development machine with Office 365 and SQL Server Express 2019 installed. The machine OS is Windows 10 Pro. In my old machine my application would run just fine. There is a query using a stored procedure that retrieves a piece of data from a table in the SQL Server backend. I call this procedure using a ADODB recordset based on the stored procedure output. All my calls use a connection string based on an ODBC DNS. This connection string works fine on the new machine when relinking tables to the SQL Server backend, but when I use it in the ADODB connection I get an error "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". On the old Windows 7 development machine this ran fine. It also runs on the client's machines which are Windows 10 and Office 365. The code that raises the error follows. The error occurs at the open connection line. The connection string is: ODBC;DSN=VROM;Trusted_Connection=Yes;APP=2019 Microsoft Office system;DATABASE=VROM1.
Set con = New ADODB.Connection
con.ConnectionString = DLookup("Link", "tblLinkData", "Use = True")
con.Open
Set rs = New ADODB.Recordset
My question "Is there a setting in SQL Server that could be causing this error?". As far as I can tell both systems are set up the same, but there is obviously something different between the two. Is there another reason this could be working on one system and not another?
Hum, where to start?
Ok, first up, if you using the ODBC panel to create a ODBC connection, then you NEVER were actually using a ADO connection in that DSN config = ODBC!!!!
That means you been feeing ADO a ODBC connection string. you can do this, but at least lets be aware of what is going on.
Next up:
Are you running the SQL browser service? You MUST do that now!. Don't know if you installed a later version of SQL SERVER, but a few versions ago you will find now that you MUST run the browser service.
This one:
The reason of course is that you can (may) have multiple instances of sql server running, and the default instance (SQLEXPRESS) now MUST BE specified. As noted older instances did NOT have this requirement. And to "resolve" the multiple instances, you now must run the SQL browser service. As noted, this was NOT a requirement in the past - it is now. That browser service is what connects the IP/server name to the instance, and you now in most cases have to run this.
There are exceptions, but you don't want much pain.
Next up:
For a VERY long time, it is recommended for Access linked tables you use a DSN-less connection. that way then at deployment time to all workstations, you don't need to setup a DSN on each workstation.
And if you link Access tables using a FILE dsn (not system or user), then upon the table link process, access BY DEFAULT converts all table links to DSN-less. That means once you linked, then you could even delete the DSN - you do NOT need it anymore.
Again: this ONLY holds true if and when you create a FILE dsn, and use that to link the tables. So, that takes care of the DSN-less linked tables.
Note that if you were to modify the DSN, you would have to link, since I just told you by default access creates + uses dsn-less links (assuming you used a FILE dsn to link).
now, you CAN of course use that SAME dsn for ADO, but that means you are feeding ADO a ODBC driver connection!!!
If you want to create a real ADO connection, then you would/could/should say use this:
Dim strCon As String
strCon = "Provider=SQLOLEDB;;Initial Catalog=TEST4; " & _
"Data Source =.\SQLEXPRESS;Trusted_Connection=yes"
Dim conn As New ADODB.Connection
conn.ConnectionString = strCon
conn.Open
Dim rst As New ADODB.Recordset
rst.Open "SELECT * from tblHotels", conn
Do While rst.EOF = False
Debug.Print rst!HotelName
rst.MoveNext
Loop
Now now how I used a "." for localhost. That could be replaced with (local), or in fact the computer (server) name say like this:
strCon = "Provider=SQLOLEDB;;Initial Catalog=TEST4; " & _
"Data Source =ALBERTKALLAL-PC\SQLEXPRESS;Trusted_Connection=yes"
Next up, make sure you enabled the TC/IP connections.
here:
However, since your case all along you actually been using ODBC driver with ADO, then I would not rock the boat.
But, check your settings as per above.
Since linked tables, and quite much everything else is DAO + odbc?
then I would probably not introduce ADO into that application for JUST calling + using sql server store procedures.
I as a general rule would say use this;
with currentdb.tabledefs("qryPT")
.sql = "exec MyProcName"
.execute
end with
Or, if it is to return data, then I would use this:
dim rst as DAO.RecordSet
with currentdb.tabledefs("qryPT")
.sql = "exec MyProcName"
set rst = .OpenRecordSet()
end with
So, I am hard pressed to find a reason to use ADO. Now of course since you been using ADO, then I guess I would continue to do so.
but, check the browser settings. And if the tables were linked using a FILE dsn, then they are dsn-less.
You could try feeding the ADO connection a existing connection from a existing linked table.
eg:
strCon = CurrentDb.TableDefs("dbo_tblHotels").Connect
strCon = Mid(strCon, 6)
Dim conn As New ADODB.Connection
conn.ConnectionString = strCon
conn.Open
Skipping the first 6 chars skips this part:
ODBC;DRIVER=SQL Server;SERVER=ALBERTKALLAL-PC\SQLEXPRESS;
UID=AlbertKallal;Trusted_Connection=Yes;APP=Microsoft Office 2010;
DATABASE=Test4;Network=DBMSLPCNM
So once again we are feeding ADO ODBC connection string.
(of course above connection string is one line).
I have an access 2010 application with a SQL Server database.
But I need to do an offline version. So I thought I would create a local SQL Server database on their computers then they can run a script to update their data before they go on the road.
NOTE: There won't be any sync. The data in offline mode is only for read-only and any changes will be lost.
I tried with Management Studio like this:
But I realized that the data is hard coded instead of doing inserts from selects.
Is there any easy way to create the script?
What I have so far is my pass through query in access to create the backup of my online database.
Then I have my pass through query to restore the backup to the local server.
The only problem is how can I build the connection string for the second query. It's currently set to this one
ODBC;DRIVER=SQL Server;SERVER=010-068\SQLEXPRESS;UID=marcAndreL;Trusted_Connection=Yes;DATABASE=SMD
but because it's a different database for everyone, it won't work.
How can we build a custom connection string?
I am using SQL Server Express 2012 and Windows Authentication, so using the answer provided here, I find this works for me:
Sub TestCon()
Dim cn As New ADODB.Connection
cn.Open ServerConLocal
End Sub
Function ServerConLocal()
''OleDB Connection
ServerConLocal = "Provider=sqloledb;Data Source=localhost\SQLEXPRESS;" _
& "Initial Catalog=Test;Integrated Security=SSPI;"
End Function
For an ODBC connection string in a Pass-through query, this works for me:
ODBC;Driver={SQL Server Native Client 11.0};Server=localhost\SQLEXPRESS;Database=test;
Trusted_Connection=yes;
Take a look at download-only articles for merge replication. MSDN.
I'm trying to access a Sql Server Compact Database.
It's a clickonce application, so I'd like it if the database can be created when the application is installed.
I got it so that when the application is started the database is created by using SqlCeEngine, SqlCeConnection, etc.
However, querying and inserting this way is complicated, so I was hoping to get it working with ADODB.
Dim MyCn As New ADODB.Connection
MyCn.Provider = "Microsoft.SQLSERVER.CE.OLEDB.3.5"
MyCn.ConnectionString = My.Settings.LocalConnectionString
MyCn.Open()
Dim rSelect As New ADODB.Recordset
With rSelect
.Open("Select wID, DirPath, Children From Watches Where DirPath like '" & dialog.SelectedPath & "'", MyCn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly)
If .EOF Then
.AddNew()
.Fields!DirPath.Value = dialog.SelectedPath
.Fields!Children.Value = True
.Update()
End If
.Close()
End With
but I get an error:
In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.
Alternately, I wouldn't mind learning how to use LINQ to SQL, as 3.5 supports it, but I haven't found how to connect to a database that might not exist until the program starts for the first time, meaning I can't use the database wizard.
It's just an opinion, why not use entity framework:
Here is a way to make the connection manual
It's just an opinion, I hope the same helps you...
You're using a SQL Server CE, this article is the walk-through for your application
http://blogs.msdn.com/b/stevelasker/archive/2008/02/11/stored-procedures-and-sql-server-compact-the-great-debate.aspx
Found some tutorials to use LINQ to SQL.
It's not quite as easy to use as ADODB is with regular SQL Server, since you have to make classes for each table, but it's not to bad.
I would like some help in creating a form with-in an MS Access front end to select a database/database server for the access backend.
A little history first;
I created a MSAccess 2007 acccdp database, it was designed as a single user to be run locally. (For a university research project with little or no funds for this).
Eventually there was a need to expand the database to be used by several people at once in the same office so what i did;
Install SQLExpress 2008r2 on a desktop.
Used Database Tools > Move Data > Sql Sever to migrate the tables to the new SQL server.
Now I want to create a second test database for development/training etc... Also, I need to adjust the properties for a different database sever (at home).
So I figure I need a form to auto exec (rather than the switchboard) which will allow you to select the database server and Database to join the linked tables to, then if successfully connects to open the switchboard.
I can create the form, but i need help with the vba to adjust the database connection properties.
I am just trying to help this project and am not a programmer in any way.
Thanks in advance
Roger
If your choice is between two connections, you can check if the existing connection is working and if not, switch to the second. However, a button may still be the best bet. This snippet works for me, but it sets the connection timeout to just a second, so the server may be available if you had only waited a little longer, and even with this time out, there is enough of a delay for an impatient person to start clicking.
Function IsSQLServer() As String
''Reference Microsoft ActiveX Data Objects x.x Library
Dim cn As New adodb.Connection
''http://msdn.microsoft.com/en-us/library/windows/desktop/ms676718(v=vs.85).aspx
''Provider=sqloledb
cn.ConnectionString = ServerCon & "Connect Timeout=1;"
On Error Resume Next
cn.Open
If Err.Number <> 0 Then
IsSQLServer = "No;" & Err.Description
Err.Clear
Else
If cn.State = adStateOpen Then
IsSQLServer = "Yes"
Else
IsSQLServer = "Maybe"
End If
cn.Close
End If
Set cn = Nothing
End Function
I need somebody to point me to the right direction, I have a MS Access DB that is updated by HP devices, and I have to sync it with the SQL Server 2008.
I have a few Ideas, and I would like to know what do you think about this:
Is there anything like triggers on access? if so can I comunicate with a SQL Server?
Is there any way to use VBA so access tell my VBA macro or whatever to make an update on SQL Server?
Is there a simple way to connect from VB 6 to SQL Server 2008?
Using a script that run at background and check DB at X minutes or seconds.
Any other ideas or suggestions are very welcome.
Thanks and like always sorry for the english.
Just to add a few points to adopilot’s answer
1) Access 2010 does have triggers and stored procedures but they are more about native access/jet tables as opposed to linked SQL tables I believe.
2 & 3) If you want to connect VB6 or VBA to an SQL server then the technology to do that is called ADO for example here is some code to open a connection and run a SQL statement
Dim dbCon as NEW ADODB.Connection
dbCon.ConnectionString = strSQL_con_string
dbCon.Provider = "sqloledb"
dbCon.Open
dbCon.Execute “UPDATE tblFoo SET bar=5 WHERE Foo=1”
dbCon.Close
4) You can either do this client side with a timer/wait event in VB6/Access or do it server side with a SQL job, not sure which is best for your situation given the limited information provided
You can refer to either the SQL Server database or the MS Access database inline in your SQL:
UPDATE SQLTable (ID, Stuff)
SELECT ID, Stuff
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'c:\External\MyAccess.mdb';'admin';'', Table1)
-- From databasejournal
You can execute this query using ADO with a connection to SQL Server
-- Connection strings
You can also do the same from the Access end with ODBC
Dim cn As New ADODB.Connection
scn = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" _
& DBFullName
cn.Open scn
s = "INSERT INTO [ODBC;Description=TEST;DRIVER=SQL Server;" _
& "SERVER=Server\Instance;Trusted_Connection=Yes;" _
& "DATABASE=test].Table2 (ID, Stuff) SELECT ID, Stuff FROM Table1"
cn.Execute s
You can run ADO with VBScript, or other suitable script and use Windows Task Scheduler to kick the script off at suitable intervals. This is not without pain.
You can try to link MS Access database to SQL server,
Now you can querying data from SQL server which is in MS Access.
I do not know about trigers on MS ACCESS but you can implement some loops in
MS SQL to periodicity count or select data for cheking new one.
To make linked server in SQL MGM Studio on Object Explorer -> Server Object -> Linked server -> right click -> New linked server
After then in new query simple call any table like
Select * from [linked server].dbo.mytable
In MS SQL there is WAITFOR command which You can implement