Legacy VB6 Application Access To SQL Database Migration - sql

My company has vb6 application with more than 100 forms. application was developed using VB6 and Access.
Now my company wants me to convert existing application from MS Access to SQL Server.
Application is using DAO to connect with Access. I've already convert Access Database to SQL With data.
Then I changed
Private db As Database
Set db = OpenDatabase(Access_File_Path, dbDriverComplete, False, ";pwd=access_password;")
to
Set db = OpenDatabase("", False, False, "odbc;dsn=Database_ODBC_Name")
All select,insert, update, delete queries works fine.
but I am getting error on such line
.Recordset.AddNew
.Recordset.Delete
.Recordset.Update
.Recordset.CancelUpdate
getting errors like
Runtime Error 3027 Cannot Update, Database or Object is read only
and
ODBC Error
Any solution or way to use existing code with SQL ?

As your error message say:
The database is read-only for one of these reasons:
You used the OpenDatabase method and opened the database for read-only access.
In Microsoft Visual Basic, you are using the Data control, and you set the ReadOnly property to True.
The database file is defined as read-only in the operating system or by your network.
The database file is stored on read-only media.
In a network environment, you do not have write privileges for the database file.
When working with a secured database, the database or one of its objects (such as a field or table) may be set to read-only. You may not have permission to access this data with your user name and password.
Close the database, resolve the read-only condition, and then reopen the file for read/write access.

Related

Microsoft SQL Server connection error with Visual Studio.net (Windows forms)

I've been trying for a while to connect the database to visualstudio.net and it just doesn't work.
First I made the database and made everything I needed there and when I tried connecting it in visual.net through datagridview (trying to get it displayed there) it only gives me access to the "System databases" in which I can't make a database.
After that I decided to make the tables under the "master" database to see if that worked and yeah I can select the database and everything but it says it's empty when I know it's not. It says it has no tables when I've checked multiple times and saw the tables I've created there.
I would appreciate some help to either be able to get for visual to accept a database I make (to be able to automatically detect it once I enter the server name) or to see how can I use the master one properly.
You can add a data source to your project and it will be able to connect to the user databases. Also, it is highly inadvisable to create any user objects in the master database.
master database is a system database and you should not create user objects in the system database. In the connection string, provide the user database name explicitly. If you dont provide the database name, it defaults to master database.
Refer to connection strings for Sql Server for providing the right connection string for SQL Server in .net.

Lock database for other application

I'm using SQL Server 2008 R2, someone is using my database via a macro code in Excel, is there any way to prevent another application (like Excel) to access my database?
If your users are supposed to acces the database (they have login and rights on it) but only with a limited range of software, you have to tell them not to use Excel.
There is a workaround based on an after connect trigger wich check the application_name in session, but its not very effective.
If they do not have to connect directly to the database, you have to delete their logins (or revoke rights) or change password if they shared a common user.
Create a service (e.g.in C#.NET) which will be used to query the database. In programming language like C# you can easily lock the database via "lock" statement.

Accessing backend tables in .mdb files from MS Access

My organization uses a user-friendly donor database software that stores its data in .mdb tables in the installation folder. The program itself uses a proprietary method of querying that is unfamiliar to me. I'm a bit familiar with SQL and want to access the tables outside of the software to do queries with SQL. The software allows us to use SQL code but we have to pay a lot more money for that feature. So I'm hoping to open the database files myself and do my own querying.
When I make a copy of the .mdb files and open them, I am not prompted for a password. I can see the table names, but when I go to open an individual table, MS Access gives me the error "Could not read definitions; no read definitions persmission for table or query." When I open it in MDB Viewer Plus I get the error "error setting table name:Records cannot be read; no read permission" I open it back up in MS Access and check out the users listed. There is only one user "Admin" and there is not a password set for it. I try to change the permissions for "Admin" to Read/Modify/Administer but it gives me the error "To change permissions for this object you must have administer permission for it."
My question is, how do I get administer permission for the database? Obviously the donor software has a way to open the databases, so how do I bypass that and open them myself?
There should be an associated MDW file in the data directory or possibly in the app's install directory. That is the workgroup file for the database and will need to be used when opening the database.
Odds are if they went to the trouble of setting up a workgroup though that they locked it down so you couldn't do what you want to do.
This is a pretty good step by step for how to open a database with a workgroup file. You can do the same thing in code too.

Creating workgroups in MsAccess 2010

I want to create workgroups in my database in MS Access 2010 such that I can provide different access levels to different users.
I tried using DDL commands creating user by CREATE USER and CREATE GROUP but I am getting syntax error stating that error in create table
Please suggest me some way so that I can provide authorization and authentication to my Database in MS Access 2010 (.accdb file).
Thanks,
Aman
User level security is a feature provided by the Jet database engine. Support for that feature was dropped from the new ACE database engine when using the new ACCDB format database. However it is still supported with the older MDB format databases.
So, if you want user level security with Access 2010, create an MDB format database and use that.

Create Access databases programatically through vb.net

Let me preface this by saying that I know this is a stupid way to go about this, but it needs to be handled in this way.
I need to make an application that from a master database creates a number of access database files (tables of a larger db), then these are manually given to users who fill in data, the database files are emailed back to a user who, through the application, combines them again.
The only part of this that I am unsure about is problematically creating the access db's. I have read that through Microsoft Jet OLE DB Provider and Microsoft ADO Ext I can create them (the tables and data), but I also need forms.
I have yet to start writing anything and this is away from my area of work, so any insight/links would be much appreciated.
Also, I would hope to be able to write this in the free express version of visual studio. Are there components needed that would prevent me from this? Thanks.
If you are developing in vb.net then why do you need forms in the Access database? Create a vb.net application for the "client" pcs with the required forms reading and writing to the Access database.
If however you do need to have forms in an Access database. Create a database with the required forms and code. Distribute the code/form database and the data database. Add a method to the code/form database the creates links to the tables in the "data" database.