Multiple readers access database - vb.net

I've read about an option in the connection string called MARS (MultipleActiveResultSets), but from what I've gathered it is only a valid argument for Sql Server 2005. Is there an equivalent setting for OleDB to open an access database with multiple readers?
I am aware that I can create multiple connections, one for each reader. I am currently doing this, but it would preferable to execute both readers on a single connection. Here's my current connection string:
"Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\MyDb.mdb;Jet OLEDB:Database Password=MyPassword"

Related

Connect Microsoft Access to phppgadmin to query in PostgreSQL

My goal is to import data into Microsoft Access to create a database which I can reference from an excel dashboard for analysis.
I can't find any information on how to connect access to allow me to query the database on phpPgAdmin.
Any advice, direction or solution is highly appreciated.
Please let me know if there more details are necessary.
MS Access is a multifaceted thing as many tend to conflate and confuse its frontend GUI .exe application and the distinct backend database (JET/ACE SQL engine which are Windows .dll files). Most of the time we refer to its MS Office app. Technically, MS Access is really the same type of product as phppgadmin: a GUI console to a database, only its default database is the aforementioned engine but can also integrate other ODBC/OLEDB-connected backends including Postgres, Oracle, MySQL, SQL Server, etc.
Through various means, you can integrate MS Access as a medium between PostgreSQL and Excel without any single migration (export/import) of data.
Linked Tables - Directly connect to Postgres tables using its ODBC Driver.
Pass-through queries - Create saved queries using Postgres dialect within MS Access.
ADO Connections (see Importing data programmatically and by using functions) - Bypass MS Access and have Excel connect directly to Postgres also using OLEDB provider or ODBC driver. Below is the programmatic version showing two connection string examples, but you can save connection objects via the Excel ribbon UI.
Dim strConnection
' REFERENCE Microsoft ActiveX Data Objects, #.# Library
Dim conn As ADODB.Connection, rst As ADODB.Recordset
' ODBC AND OLEDB CONNECTIONS (SELECT ONE)
strConnection = "Driver={PostgreSQL};Server=IPaddress;Port=5432;" _
& "Database=myDataBase;Uid=myUsername;Pwd=myPassword;"
strConnection = "Provider=PostgreSQL OLE DB Provider;Data Source=myServerAddress;" _
& "location=myDataBase;User ID=myUsername;password=myPassword;"
conn.Open strConnection
rst.Open "SELECT * FROM myPGTable", conn
By the way, above is the VBA version to be run in an Excel macro but ADO is a COM object and hence can be integrated in COM-interfaced languages including PHP, Python, R, Java, etc.

Use of database name in connection string

What is the use of mentioning the database name in connection string while opening a connection from dot net application to SQL server? Because even though we mention a database name in connection string we have to explicitly write the fully qualified name (DBName.schemaName.ProcName) while calling a stored procedure if the default DB is different for that particular user.
Connecting to database from a .NET application is different from accessing a table of different database.
use of mentioning the database name in connection string
so for instance you can use connection string below to connect to myDB at MyServer
Data Source=MyServer;Initial Catalog=myDB;Integrated Security=True
if you will not specify at least these information how your .NET application can connect to a stored procedure (MyProcInMyDB) located in myDB.
Now for part you asked
though we mention a database name while calling a stored procedure if
the default DB is different for that particular user
this is not a normal case to access stored procedure of another database using same connection string if it is a very special case (not likely) then you will do it for calling one or two stored procedures. But if it is required quite often within your application then you should create a separate connection string. Using same connection string and calling like
command.CommandText = "myDB2.dbo.getList"
can result is difficult maintenance and flexibility

Connect SQL Express 2012 vb.net

I have been working on this for a few days now. I am trying to make vb.net forms app for my database. Right now I am working on a login form and a main form. I have researched many different websites and played with this string forever, but i can not get a connection to my db. I get different errors saying the machine refused it, then ill get a timeout error, then it will go back to refusal.
Dim conn As New MySqlConnection
If conn.State = ConnectionState.Closed Then
conn.ConnectionString = ("Server=192.168.0.2;Database=Sunshinetix;User=sa;Password=sunshine;")
End If
Can someone please tell me what I am doing wrong? I am a beginner in vb.net. And this is a remote server, but LAN.
Thanks!
PS: Is is because I am using SQL Express?
Enable remote connections for SQL Server Express 2012
I've had that article open for a few days and it has helped me a lot to this point.
If you are using Sql Server express, you need to use a SqlConnection, not a MySqlConnection. That one is for use with MySQL, which is a different implementation of SQL than Microsoft SQL Server
Of course, Microsoft also offers the OleDbConnection as kind of a "catch-all" (see more here: Difference between Sql Connection and OLEDB Connection). Still, if I know I'm going to stick with a particular SQL provider, then I generally use the specialized version.
Also, if you're ever interested, here is a small list of common SQL providers:
Microsoft SQL Server - proprietary SQL provider developed and supported by Microsoft
MySQL - Free, open source relational database system developed by Oracle. Very popular with web developers.
PostgreSQL - another open-source RDBMS. Gaining popularity due to its flexibility and adherence to standards.
SQLite - a small, SQL provider with an emphasis on portability. Unlike the others, it uses local database files rather than a remote server. This has made it pretty much the default choice when developing mobile applications that require local storage.
Try this:
Dim SQLConn As SqlConnection = New SqlConnection
SQLConn.ConnectionString = "Data Source=servername;" & _
"Initial Catalog=databasename;" & _
"User ID=username;" & _
"Password=userpassword;"
The reason why you can't connect is that you are using MySQLConnection that is connectiong to connecting to MySQL DB which is different from MS SQL so you need to use SqlConnection
You might also check this:
http://support.microsoft.com/kb/308656
Also check this site:
http://www.connectionstrings.com/sql-server/
To know preferences of your SqlConnection string according to SQL version.
Try this to test your connection string:
Dim connectString as String = ""
Try
Dim objConn As SqlConnection = New SqlConnection(Server=192.168.0.2;Database=Sunshinetix;User=sa;Password=sunshine;)
objConn.Open()
objConn.Close()
Msgbox("Successfully connected to database!")
Catch ex As Exception
Msgbox("Cannot connect, Error:" & ex.Message)
End Try

Connection string to a SQLite Database using ADODC/ADODB

Can ADODC/ADODB be used to connect to SQLite?
If Yes- what is the connection string that can be used?
If No- is it only to connect MS Provided DataBases?
There is a reference that can be used? SYSTEM.DATA.SQLITE (It is not efficient)
Can you suggest me any other references (If not ADO)?
I want to use VB.NET to connect to a SQLite backend.
I Use ADODB Recordset to connect on SQLite database. For that You need this provider and
"DRIVER=SQLite3 ODBC Driver;Database=" & BasePath
for the connection string.
Beware of some restrictions : SQLite has no defined type for each field. Therefore if you misspell a date format or float, the provider with give you an error when you try to update the record.

access to SQL copy

We have an Access DB which has a set of local tables and input forms etc. in which a user maintains their data.
We also have a SQL DB with the same tables which is used to displays the data in a web search form.
What is the best way to allow the user to udate his changes to the SQL db while keeping the working copy local so he can work offline and then push the files when he is happy with new version of the data?
My first thought was add the SQL tables as linked tables I could then truncate (access does like that) or delete the content in each table and then do an insert for each table.
Can I call a SP from access on the SQL to truncate the tables as I am have problem running deletes
I really do want to get it down to the user running a macro/sql call that is repeatable etc.
Thanks for your help
You should be able to use the ADODB.Command object to execute stored procedures.
EDIT:
This example is copied from Using ADO in VB and Access
Sub ADO_COMMAND_CONNECTION_TEST()
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset
Dim strConn As String
cmd.ActiveConnection = " DRIVER={SQL Server};" & _
"Server=UKDUDE;DATABASE=pubs;UID=sa;PWD=;"
cmd.CommandText = "byroyalty"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Refresh
cmd.Parameters(1).Value = 25
Set rs = cmd.Execute
' Recordset now has authors with 25% royalty.....
End Sub
Don't ever use MS Access linked tables with MS SQL.
Not only are they slow, but Access can leave open client-side write cursors on the tables referenced. That's a really dumb way to create lots of deadlocks, but Access does it anyway.
Microsoft significantly improved this when they added Access Data Projects - in these the entire back end is replaced with SQL and Access just supplies the forms.
If you want user actions to write directly back then ADPs are by far the best method.
If you want to cache changes locally in your Access DB and then send them up to SQL you have a far more complex problem. You will need to be far more specific on exactly how you want synchronisation to happen - for instance if two users make offline changes who wins when they connect?
I don't understand why you just don't link directly to the SQL Server data and use it directly, rather than going to the trouble of maintaining a second copy of it. This is the standard Access way to do things -- why are you resisting the natural capabilities of the tool you're using?