How to override or workaround compiled DB connection info - sql-server

I've faced a bit strange problem. There is a site client would like to duplicate on another domain name. Site is built on ASP(yes, old v1 ASP :( ) with SQLServer. Problem is that all the database operations, including connection information is compiled into a DLL library.
Is there a way to some how intercept, override or workaround this?
Platform:
Windows 2000 Server
SQLServer 7
ASP v1 (VisualBasic)

What a nightmare...
If you have control over the new database server, and the connection string references the database server by name, you could add a line in the hosts file which points the name of the old server to a new ip address. Then you still have to create a user with the same password on the new database server.

Yes! However, your new database name MUST be smaller or equal to the length of your old one. Simply open up the vb6 .dll in any Hex Editor and search and replace. Make SURE you do not change the length of the DLL or shift any bytes around.
Failing that, add a hosts entry to windows to redirect the connection.

Could it be that the application uses a DSN definition for the connection?
In Control Panel -> Administrative Tools open ODBC Data Source Administrator. Have a look at the System DSN tab. Does there seem to be anything listed there that is related to the application?

Before you hack your DNS or rename the server, be aware that the SQL Server client supports aliases specifically for this scenario: How to: Create a Server Alias for Use by a Client.
The SQL 2000 tool for configuring an alias is the Client Network Utility.

Do you have any configuration options at all from asp? Even dbname or the such? If so you might be able to use two separate servers for IIS and use a single db server. I'm afraid you might need to find the source or the guy who wrote it.
If you could figure out the connection string or DNS you might be able to do something.
You could write your own passthrough ODBC provider.

Related

Can't connect MS Access front end to SQL Server back end

I have imported data to SQL Server Express from MS Access and have tried to link to the data from an Access front end file.
I have tried several different login types, but each gives me the same error:
Error Locating Server/Instance Specified
Please help.
Assuming a local instance of SQL server?
The default is usually YOURCOMPUTERNAME\SQLEXPRESS.
But, you can use a "." (dot) in place of your computer name.
So, the server name should be .\SQLEXPRESS
A few things:
When you setup and attempt to connect? Always create a FILE dsn. The reasons for this are many, but one really nice reason is that then Access will by default create a DSN-LESS connection. This approach is preferred since then Access remembers the settings, and no external settings (such as registry or even a file (dsn) is used or required. And if you connect to a SQL server on your network? Well then you can distribute the access application to each workstation, and it will "just work" - all without you having to setup a DSN or do anything with the ODBC manager on each station. So, a great tip and habit. So, use a FILE dsn (and if you follow the default prompts when linking tables, a FILE dsn is the default anyway).
Next up:
Make sure the sql server browser service is running. In the past this was often not required, but now it is recommended. That service is this:
Once you sure that service is running?
Make sure that you enabled named Pipes - in fact I would also enable TCP/IP. That is found here:
Ok, now the next question:
Are you using SQL server logons, or Windows authentication?
For now since this is your local stand alone machine? lets go with windows.
As noted, if you have SSMS installed, then see if it can connect. This not only is a quick + easy fast test but it will also tend to give you the hints as to what the server name connect is. (this helps you when you attempt to connect with Access - you can see what worked with SSMS - and better is SSMS does usually figure out the correct computer name for you.
So, from Access, you now choose from ribbon "External" data, and then import and link group - choose ODBC.
the wizard to connect will start. choose "link to the data source".
At this point, the panels that start to launch are the same one you see if you try to use the ODBC manager from the control panel - but in most cases this road is better, since Access will correctly launch the x32 or x64 bit ODBC manager (it makes this correct decision for you).
So you be at a DSN name, but just hit new. Now you have to choose a ODBC (for sql server) driver.
For now, I would try "SQL server". You can choose SQL Server Native Client 11 (or later if you see). Either one is fine. Just keep in future mind that SQL Server driver choice exists on all computers - so for future distribution to other workstations, this is a good choice. The native 11 (or later) driver is NOT installed by default, and you have to install this on other workstations if you want to use that driver if you move or distribute your application to other workstations.
Next, and now you can enter a name for this connection (myTestcon or whatever). Hit finish.
You should now see/be at this screen:
The dropdown for the server name SHOULD appear and work (it make take 30 seconds). So, it should show you a server name, and a sql instance.
Next, and now you have to choose the type of logon
Because this is a local stand alone computer? Well, you can choose windows logons, or sql logons. Being a local computer - choose the default - windows auth.
Next.
NOW VERY VERY important - make sure you change/select the correct database here - SO MANY skip or miss this - and that's painful!!
This one:
So make sure you select/change the default from "master" to your database you created when you sent the data to sql server.
Next - (you can try the test data source). "ok".
Now you are back to the VERY same starting panel. Your "name" should be defaulted for the file connection. This:
So, now just click ok.
You can then select the tables you want to link to.

How to Use Same SQL Connection String After Server Name Change?

We have a set of over 10,000 Excel files that were all created from a template (don't ask). They all use the same connection string to connect to a SQL Server database. Now the name of the server is changing and there is no simple way to globally replace it in the connection strings of all 10,000+ files. Is there any way to keep the same connection string and still have the files be able to connect?
The server name is changing from "ABCNT3" to "ABCSQL16P1", so I need a way for the line "Data Source = ABCNT3" to still connect to ABCSQL16P1. Really hoping it's possible.
Disclaimer: This is a little hackish, which will make it difficult for another person to maintain this after you. However, considering your (already) bad situation, this will solve your current problem until you can determine a more-permanent solution.
If you don't already have SQL tools installed, you will need "SQL Server Configuration Manager". I installed it as part of admin tools for SQL 2017 (SSMS).
Run it from the machine with all of your Excel files.
Once it opens, pick the last one from the list, named "SQL Native Client ##.# Configuration". Expand it and choose "Aliases".
Create New.
Alias name = "ABCNT3", Server="ABCSQL16P1".
Your Excel will believe that the new server is the old server. It is pretty seamless.

Attempting to Distribute an Access Application with SQL Server Backend

I am attempting to use a Packaged Solution for my Access 2010 application that has its backend linked to SQL Server. At the moment, I'm using the .accdb file as the frontend, and I would like to distribute my application to some other Windows computers, but the Packaged Solution does not work. I had the package include Access Runtime, so their version of the frontend is running on Runtime and not full Access. However, once the application makes a request to the backend, the application does nothing, as I am not even prompted for the SQL Password as per usual with the full version. I've read on about including a .dsn file in the package can secure the SQL connection (see here), but going through steps of other tutorials to create .dsn files hasn't led to any results. Would anyone know how to correctly generate the .dsn file or if I've done something else wrong at this point?
(And yes, I understanding using Access 2010 in the year 2019 is almost a joke at this point, but I'm doing this for testing purposes. I plan to completely remake the frontend in Angular in the future.)
One other unrelated note... would it be a better idea to have the frontend hosted as a .html file like through the "Publish to Access Services" process? I did read that Access Services was discontinued last year, so would that not be possible?
Edit: This is not a duplicate of "DSN Less Connection (MS Access to SQL2016)" because A) I want to utilize a DSN Connection, not DSN-less and B) I am not using connection strings in my code to hook up with SQL.
You should be able to just create FILE dsn, link your tables, and then distribute the compiled accDE to each desktop.
However, what SQL odbc source provider did you use? If you use the SQL server ODBC provider, then that is by default installed on each computer.
However, if you linked using Native 11 (or later), then that driver is NOT installed on each workstation by default. So, I HIGH recommend you create a FILE dsn (not a user or system DSN), and link the table using that. (Access will create DSN-less links for you)
And you should NOT be seeing a logon prompt with your application. This suggests you forgot or missed the save password option.
So, I would re-link your tables, creating a new FILE DSN. And if you using the linked table manager, then make sure you check the prompt for new location to force creating of a NEW DSN. If you just re-fresh, then you DO NOT get a chance to click on the save password option during the linking process.
So, what odbc driver are you using? The native 11 or later are better, but they are not installed by default on each workstation. However, CAUTION is required here, since the older sql driver does NOT support the newer datetime2 formats. If you used these newer sql column types, they will be returned as string data types in Access and create a mess of issues.
So, first, I would re-link using a FILE dsn.
Make sure you check the save password during the re-link.
You then compile your accDB into an accDE, and then distribute that. You don’t really need to use the package wizard, since once each workstation has the runtime installed, then a simple copy of the accDE to each person’s computer will thus work fine. There is NO special connection between your accDE and the package wizard. Once the runtime is installed, then any and all mdb, accDB, and your accDE can simply be clicked on to launch + run. So for testing, you can skip the package wizard, and just copy the accDE to the target machine, click on it, and see if it works.
Edit
The prompt and check box during this process is this:
So you have to check that box to save the password. Note that you ONLY get this dialog WHEN you create a new FILE dsn.

Users on my network cant open the Sql server linked tables from their MS Access Form

Hi there hopefully this makes sense.
I have split the database into backend and Frontend.
In the frontend i also have added some linked tables from a SQL Database which are on the network. The DNS files are in the same folder as the front. Now when ive copied across the frontend to the end users desktop when they try to open the table via a form they get the error: "ODBC Call failed" anyone know why that might be?
1 of the end users is using the free version of ms access(2016 runtime) and other has full MS Access but both get the same error.
As it wasnt happening during the development stage on my computer and my collegues. I am a bit lost on how to fix the issue other than convert the linked tables to local tables and do a weekly update of them from the SQL server via my computer where the links work.
Seeing as a normal backend table that is linked to the front works fine. Just would like it to directly call the information from the SQl Server.
Make sure on your development workstation you link the table using a FILE DSN. When you link, Access then converts the links to what we call DSN-less.
The above means then you don’t have to copy or setup or use ANY kind of DSN on each workstation. So do NOT use a “system” DSN – that uses settings in the registry that you have to setup on each workstation.
The next issue to be aware of is which SQL driver you use to link the tables. If you use the “standard” SQL Driver when linking, then you can be SURE those drivers are installed by default on each workstation.
If you use “Native 11” (or later), then you have to ensure that the Native 11 (or later) drivers are installed on each workstation for this to work. The native drivers are better choice, but they are not by default installed on each workstation.
So I suggest you delete the links, or use the linked table manager to re-link the tables – just make sure you use a FILE dsn – since once the tables are linked, then Access ignores and does not use the DSN anymore – you don’t need it, and you could even delete the DSN and you linked tables will still work.

Can't access the DataBase (.mdf file) in my WPF application from PC's on network

I created a wpf application which connect to some sql database tables.
When i run this application on my pc every thing works fine,but when i try to run it from other pc on the local network i got an error: "The file ("file name") is on a network path that is not supported for database files".
What is the best way to create a WPF application that have to run from some pc's on the local network that share a common DB?
Have you considered a database server, SQL Server, MySQL, or something similar? If you really want to stick to a file based database (something I wouldn't recommend for security reasons) then you can use something like SQLite.
You will only be able to connect to your server (your pc in this case) instance from another pc if you have 'named pipes' enabled. You can also enable TCP\IP etc. if needs be, but this is probably why you are getting the error.
Named Pipes is not available in the Compact or Free versions of MSSQL.
A database server or pc with a proper version of MSSQL is your best bet.
yepppp solved.
Thanks for your answers.
I did some things that finally solved my problem:
1. Remove the "uid=Tomer, pwd=, and pooling=False" from the connection string.
2. Enable Port 1433(sql port) in the firewall.
3. Enable the TCP/IP and the 'named pipes' as i mentioned before.
Thanks alot for your help.

Resources