I have an access 2000 application to manage. The DSN is pointing to the production Postgresql database and I'd like to point it to the one running on my machine for testing.
The problem is, I can't figure out how to change it. I tried running odbcad32.exe, and I did see the DSN and was able to change it to what I wanted (and it did pass the "test connection" test), but it still seems to be connecting to the old production dsn. I confirmed this by checking the connection logs that get dumped to C:\. I searched the registry for the production server's name; I could not find it (and I verified that my changes were getting posted to the registry. I searched the entire project's forms' sources for the server name, I could not find it there either.
Where else could Access be getting the dsn from?
Don't use DSNs. I much prefer DSN-Less connections as it is one less thing for someone to have to configure on each PC and one less thing for the users to screw up.
Using DSN-Less Connections
ODBC DSN-Less Connection Tutorial Part I
HOWTO: Use "DSN-Less" ODBC Connections with RDO and DAO
Carl Prothman's Connection String Home Page
Relink ODBC tables from code
Also it's easier to have a setup that uses a development connection string for you and a production connection string for everyone else. For example, assuming your users only get MDEs/ACCDEs, you could use the following function to determine which connection string to use
Public Function tt_IsThisAnMDE()
On Error GoTo tagError
Dim dbs As Database
Set dbs = CurrentDb
Dim strMDE As String
On Error Resume Next
strMDE = dbs.Properties("MDE")
If Err = 0 And strMDE = "T" Then
tt_IsThisAnMDE = True
Else
tt_IsThisAnMDE = False
End If
Exit Function
tagError:
Call LogError(Application.CurrentObjectName, "")
Exit Function
End Function
Apparently MS Access stores the whole connection string, not just DSN name. Here is what I see opening .mdb file in Notepad:
DSN=SQL-Northwind;APP=Microsoft Office 2003;WSID=DELLNOTEBOOK;DATABASE=Northwind;Network=DBMSSOCN;Address=LOCALHOST;Trusted_Connection=Yes
MS Access comes with Linked Table Manager however it won't update DSN once it's changed (at least not for me).
I guess your only choice is to delete a link and create a new one.
Related
Sorry for possible dublicate.
I am trying to connect to my MySQL database from my LotusScript code (in some of my legacy projects):
Option Public
Option Declare
UseLSX "*LSXODBC"
Sub Initialize
Dim mysqlConnection As New ODBCConnection
Dim sqlQuery As New ODBCQuery
Dim result As New ODBCResultSet
Call mysqlConnection.ConnectTo("url","root","111111")
If Not mysqlConnection.IsConnected Then
MessageBox "No connection. Try again later."
Exit Sub
Else
MessageBox "Connection success."
End If
End Sub
I can't figure out what is the correct way to set the url of my database in LotusScript. I have already tried many variants of possible solutions, but nothing worked, also found many different urls, but also not helped.
Situation:
For example, I am trying to connect to my localhost MySQL base in port 3306 with name "test_db".
Question:
How must the url looks like for this?
p.s. also, if you have more possible ways to connect to MySQL DB from LotusScript - I will be very glad to see them.
Thanks.
As per the documentation for the ConnectTo method of ODBCConnetion class, you don't specify a URL. You specify a Data Source Name, otherwise known as a DSN. This is a name that you assign when you configure a connection in the 'Data Sources (ODBC)' tool on the Windows machine where the code will be executing.
On Windows 10, the 'Data Sources (ODBC)' tool is found in the Control Panel listed under Administrative Tools. On a Windows 2008 server that I happen to have handy, Administrative Tools is directly on the Start Menu. I'm sure they've hidden it in other places on other Windows versions. (I have a dim memory of it being under 'Accessories' on some versions.)
Note that on 64 bit versions of Windows, you need to be cognizant of whether your code is running in a 32 bit environment - as it is if it runs in the Notes client, or in a 64 bit environment, which it might be if it is running in background on a Domino server. There are separate 32 and 64 bit versions of the 'Data Sources (ODBC)' tool, and it does matter which one you use. If you're at all unsure, run them both and configure the same DSN name in each of them,
i have created an installer for my vb project. it tried to install it to my work PC and it worked. I then installed it to a different PC. It was installed successfully but when i tried to to run it, the system was unable to connect to my database. It is giving me an error:
Can't connect to MySQL -unable to connect to any of the specified mysql hosts
I only created an installer that has the .exe in it and the database, nothing else.
Am I missing some requirements or additional application that is needed for a vb.net application with a mysql database to run smoothly on a different PC? what is it?
What causes the issue?
thanks in advance!
As we discussed in the comments above, using 'localhost' to connect to your MySQL server only works on the machine where the server is installed. To connect to your server from other machines, allow the user to enter the path to your server and save that information outside of your MySQL database so that the user doesn't have to enter it every time.
First, if you don't have a properties file already, create one by saving a .txt file in your project's bin folder. (For me, that's Documents\Visual Studio 2013\Projects[PROJECT NAME][PROJECT NAME]\bin\Release - the path is likely the same or similar for you.) If this is all you're storing, just type localhost in the txt file and save it as properties.txt. If you're still debugging, copy the file to the bin's Debug folder as well.
Imports System.IO
Dim filePath as String = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "\properties.txt"
Dim serverPath as String
Using fReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(filePath)
fReader.TextFieldType = FileIO.FieldType.Delimited
fReader.SetDelimiters(",")
Dim currentRow As String()
While Not fReader.EndOfData
Try
currentRow = fReader.ReadFields()
'If you have other values stored here, check that length of currentRow matches the number of properties you expect to import and import anything else you have saved here
serverPath = currentRow(0) 'or whichever place you save it in your file
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
'File is not formatted as expected
End Try
End While
End Using
Place the above code at an appropriate place in your project so that it executes once before you try to connect to your database. Then take your existing code to connect to your database, replace "localhost" with "serverPath" (concatenated into your SQL command, of course) within this code:
Dim oldPath As String = serverPath
Do
Try
'Your existing code with the server path passed as a variable here
If serverPath <> oldPath Then
'The path that worked isn't the one that was saved. Update file
Using file As FileStream
file.Open(filePath)
file.Write(serverPath) 'Update to meet your needs if you have other variables stored here.
file.Close()
End Using
End If
Exit Do
Catch ex As MySQLException
'The path saved in your file is not working. Get a new one and try again.
serverPath = InputBox("Please enter the directory to the database server:", "Unable To Locate Server")
If serverPath = "" Then
'User either clicked Cancel or left field blank
Exit Sub 'Or whatever else you want to do when the user aborts
End If
End Try
Loop
Give that a whirl. There are other ways of reading and writing files you can look into, but this should do everything you need.
I am calling this rs.exe script to run and export the report:
rs -i RunReport.rss -s http://localhost/reportserver -u myUsername -p myPassword -e Exec2005
The error I get is:
Could not connect to server: http://localhost/reportserver/ReportService2005.asmx
Currently all of our reports are set up to use 'Credentials supplied by the user'. If I go to the report and input the username and password, it runs just fine. It just doesn't work running the script.
When I change the report's datasource to use Windows Integrated Security, the script works.
Any ideas on how what I'm doing wrong? Or alternatively, is there a way to change the report's permissions to Windows Auth and then change it back?
SSRS 2012
My rss script is
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim format as string = "EXCEL"
Dim fileName as String = "C:\test.xls"
Dim reportPath as String = "/MyDirectory/Report1"
' Prepare Render arguments
Dim historyID as string = Nothing
Dim deviceInfo as string = Nothing
Dim extension as string = Nothing
Dim encoding as string
Dim mimeType as string
Dim warnings() AS Warning = Nothing
Dim streamIDs() as string = Nothing
Dim results() as Byte
rs.LoadReport(reportPath, historyID)
results = rs.Render(format, deviceInfo, extension, _
mimeType, encoding, warnings, streamIDs)
' Open a file stream and write out the report
Dim stream As FileStream = File.OpenWrite(fileName)
stream.Write(results, 0, results.Length)
stream.Close()
End Sub
I had the same error, it was due to a mistake in the configuration: the script was set to run against the Report Manager URL and not the Web Service URL (both can be found in the Reporting Services Configuration Manager). Switching to the Web Service URL solved it for me.
(I reckon you've found a workaround in the last 3 years, but I'll put this here if someone else is struggling with the same problem)
Came across the same issue. Addressed it by changing the Reporting Service Configuration Manager database credentials from Integrated Security to SQL server admin account.
I had a very similar problem. For me, getting rid of the default credentials fixed it. I asked our network guy to make a set of generic credentials (with a static password) and used that instead.
rs.Credentials = new System.Net.NetworkCredential("ACCOUNTNAME", "PASSWORD", "DOMAIN");
Let me know if you still have trouble with this. I spent a lot of time on errors related to this. You also might be able to check your SSRS log files for more information.
I had the same error message (Could not connect to server: http://localhost/reportserver/ReportService2010.asmx).
I was able to solve the issue by re-creating the report server database using Reporting Services Configuration Manager.
Connect to SQL Server using SQL Server Management Studio
Delete the report server database (called ReportServer or ReportServerSQLExpress)
Start Reporting Services Configuration Manager (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft SQL Server 2012\Configuration Tools\Reporting Services Configuration Manager )
Choose Database
Click Change Database and following the Wizard to create a new report server database
I had the exact same problem as you. For me it was caused by a Windows Credentials was somehow created for that URL. I've seen this happen to users also, but at the time I did not know how to resolve the message. They just signed in and kept moving. For me, the issue I was having was not isolated to chrome. I could also not use the command line to execute a tool (RS.exe), the command line said 'Could not connect to the server'.
The gcod049/reports URL issue was resolved after I deleted the saved credentials in Windows Credentials Manager.
Fig1: Sign in issue
Fig2: RS.exe issue
Fig3: Credentials Mgr
-- Control Panel\All Control Panel Items\Credential Manager
-- remove from vault: "gcod049"
Fig4: RESOLVED
-- browser sign in prompt gone
-- RS.exe connects to the server
I am new to classic ASP. I would rather ask question than do hour of research to solve my problem.
I am accessing access database and getting the following error.
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/default1.asp, line 30
The culprit line is this
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("c:\database\MyDatabase.mdb")
Well, I do not have Access installed but I copied the .mdb file to the specified folder, will it work that way? I am familiar with SQL Server, and that has to run in order to retrieve data from it.
It uses ADODB but I can't file the DLL. Can someone specify the DLL for me. What I have to do to get it working. Just registering it will work using regsvr32 my.dll?
I could not find a connection string (I usually use a connection string to connect to my SQL Server). Do I need one for Access database in this case?
Please help
It's been a few years for me, so this answer might be a little out of date. Also, since the Access db ends in .mdb, I'm assuming that it's a pre-2007 database.
Yes, just the file should work. Access does not need to run, it just needs to read the file. However, you may need certain components installed to talk to the Access database (used to be MDAC
- http://www.microsoft.com/download/en/details.aspx?id=1953, not 100% certain if it still is). MDAC contains the JET engine, which classic ASP uses to talk to Access files.
As for the connection string, this web site that provides some examples of access connection strings: http://connectionstrings.com/access
edit - adding more info
Just in case I'm not following the comments correctly, here's an example of how to connect to the Access database through Classic ASP:
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = "c:\database\MyDatabase.mdb" ''# Server.MapPath is not needed, since we are providing the whole path already
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & MdbFilePath
When running the code above, do you receive the error still? Also, what's the set up you're running (IIS7, IIS6, 32bit, 64bit)?
I'm trying to connect to an Access database file using a System.Data.OleDb.OleDbConnection. I need to connect in readonly mode because another application uses it at the same time. I can connect to the database in read/write no problem but can't seem to find anywhere the correct string for readonly.
I've tried:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=False;Mode=Read
Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=False;Extended Properties="ReadOnly=true;"
Thanks.
EDIT:
(I should have put more information in the original question.)
I could connect successfully to the access database when it was on the local machine, but when I tried connecting to the access database on a remote machine with the connection string
Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=False;Mode=Read
I would get the following error:
System.Data.OleDb.OleDbException (0x80004005): The Microsoft Office Access database engine cannot open or write to the file '{0}'. It is already opened exclusively by another user, or you need permission to view and write its data.
My application is running in a windows service under the local system account.
I think that has to be handled either by user permissions that the DB admin would control, or with different cursor types for your recordsets, which you would control. I don't think the connection string specifies access mode, it just gets you there. ;)
The real problem is that Excel leaves the connection open until the file is closed.
In Excel 2007+, the MaintainConnection setting is set to true by default. You need to go into the vb editor and use code to turn it to false. I haven't seen a way to do this through the visual interface.
Even if you set the connection string to readonly, it will lock an access database (from my experience).
For a pivottable connection:
Sheets("sheet1").PivotTables("pivottable1").PivotCache.MaintainConnection = False
For QueryTable:
Range("A2").Select
Selection.ListObject.QueryTable.MaintainConnection = False
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
By setting it to false, the table will connect, run the command, then disconnect, releasing the lock.