Connecting Excel VBA to oracle DB using 'ODBC' - database

Basically i work in a software company.
My client has a Oracle database.
I do access that database through SQL Developer.We have a virtual desktop too -inside which we have all client applications,SQL Plus etc..!!
Now one other person in my team has created a excel macro in which if you give your username password and your SQL query, it will connect to the oracle database and fetch the records for you and will save it in an excel sheet in the virtual desktop itself.
Now i want to do something similar but i am not able to fins how i connect my excel VBA to Database. As his macro is able to connect to the database i am pretty sure all necesaary drivers are installed in our virtual machine(desktop).
I can see "Oracle - OraClient11g_home1" in All programs in my virtual machine.I can see SQL plus and all those apps. Giving all these details because i read in other posts that these things may be required to connect to DB.
In SQL Devloper if i go to connection properties it shows me the Network Alias name as "xxxxxx"(I have replaced by xx).Connection type as 'TNS' and role as 'Default'.I know my username and password.
Note: In Excel when i go to new connect database option, i dont see Oracle Driver at all:( I can see only "Microsoft Driver for Oracle".
These are all the details i know . Can someone help me with connecting to Database.Once someone can help me do it rest everything i can do in my macro.:)

I just tested it following these steps:
Excel > Data > Get External Data > From Other Sources > From Data Connection Wizard
From Data Connection Wizard, select "Other/Advanced" and click Next
On the Connection tab, create new connection string by click on Build
On Machine Data Source tab, click New
Select Oracle driver
Enter corret "TNS Service Name" and your user id. Click test connection and enter your password.

Related

Access won't connect to a different SQL Server database

I have an Access application that writes to a SQL Server database. I would now like it to write to a different SQL Server database instead.
Made sure the new database if properly configured with dbowner permissions for my user credentials
Wrote a test record using that user credentials
In the Control Panel, set ODBC source to the right database. Tested connection successfully
In Access, Database tools > Visual Basic section, I changed the connection string and substituted the login credentials with the new userid and password.
But when I input values in the form, it STILL saves to the old database.
I did notice that in the Linked Table Manager, the linked tables still point to the older database. But when I select all and click OK, the message is 'All selected tables have been successfully refreshed'.
What do I need to do to point the tables to the new database?
Edit
I did a 'Find' for the old database name and edited the connection string on all the forms where-ever that old database name existed and replaced it with my new database name.
Example:
.ConnectionString = "Provider=SQLNCLI11;Data Source=(old datasource name);Initial Catalog=(old database name);User ID=(old userID);Password=(old password)"
changed to
.ConnectionString = "Provider=SQLNCLI11;Data Source=(new datasource name);Initial Catalog=(new database name);User ID=(new userID);Password=(new password)"
It sounds like you need to delete your old linked tables and create new ones. If you hover over the linked table it should show the connection string.
If you are worried about losing your old linked table, you could rename it to something else.

Connecting to sql database

(I am a sql noob and I just can not figure this out on my own)
For some time now I have been trying to establish a connection to a SQL database in codename one but to no avail. First I tried connecting to a MariaDB database from one.com. All that's needed for the connection is
Database db = Display.getInstance().openOrCreate("databaseName");
if I am not mistaken, but I am guessing this implies that I have somehow already established a connection to the database. This is not the case however so it creates a new .sql file, right? I can recall that you can connect to a database in the services tab in Netbeans. I chose the MySQL(Connector/ J Driver) which should work with MariaDB, or should it? I entered all my data and i says that it can not establish connection to the database.
the error i get
So I thought I might as well try using localhost. I used XAMPP to host a database and connected in the netbeans services tab.
connected?
Now testing was needed to see if this works. I started the SQL journey with this https://www.codenameone.com/manual/files-storage-networking.html#_sql and integrated the part after "You can probably integrate this code into your app as a debugging tool". I changed database name to "mybase" (it's existance can be confirmed in picture 2). Ran the app, opened the dialog, entered "select ID from customers" and got: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: customers) It does not get past the first call to "executeQuery". The customers table definitely exists so what am I missing to establish connection?
I really need instructions to connect to the localhost database and ideally also to the one hosted by my webhost provider.
Thanks,
Jona
The Database class is to access the SQLite DB on the mobile device. To connect to external databases, you'd have to do something different, such as a ConnectionRequest or Socket I think.

Transfering Data From Production Server To Development Server

I am want to make the following statement:
INSERT INTO [Server_1\Instance_1].[Database].[dse].Table1
SELECT * FROM [Server_2\Instance_2].[Database].[dse].[**Table1**]
The point is the tables are on the different servers. I tried with the statement above. However, when I am on server_1 and when I run the following statement in order to retrieve the data from server 2:
SELECT * FROM [Server_2\Instance_2].[Database].[dse].[**Table1**]
... I get zero rows.
But when I run the statement above on the Server_2, I get a set of rows.
How can I transfer data from production to development server/environments?
I am using MS Management Studio.
UPDATE:
The error message I am getting when I run the select statement in order to retrieve the data from another (production) server:
The OLE DB provider "SQLNCLI10" for linked server "Prod_Server\Instance" does not contain the table ""Database"."dse"."BoxIteration"". The table either does not exist or the current user does not have permissions on that table.
Select statement is:
SELECT * FROM [Prod_Server\Instance].[Database].[dse].[BoxIteration]
Two things to take into account:
add the source server as a linked server in the destination server
verify that the credentials specified while creating the linked server have access to the data in the source server
I have a localized version of SQL Server, so the transalation may not match what you will see in your screen: open Object Explorer window in SSMS, connect to the destination server, open the tree and look for Server Objects, Linked Servers. Right click on the source linked server, and see the properties. Open the Security pane, and see which credentials are used to connect to the linked server.
Once you do so, you have to check the permissions of that credentials on the source server to verify that it can acccess the table in question.
If you don't understand, or can't do some of the steps (for lack of permissions), get help form your DBA: he will understand and solve the problem at once.
If u have access(Having credentials) to both prod and dev Db servers you can use "Import and Export Data"
1.Go to start and open "Import and Export Data"
Wizard will open give source server name, credentials and Database(For your case Prod)
Then give destination server name, credentials and Database(Dev)
Select the table , if there any identity column -->"Edit Mapping" and Enable identity insert.
Then give next--> it will start copying.

Prompt for SQL Server to connect to in Visual Basic 2010

I have a project that current uses a hard coded SQL connection string. I want to make this more flexible so that when I move it to another environment the user can browse for the SQL server to connect to since it will have a different than my test server. I have tried countless ways to Google for a solution and I am just not getting any hit. I am looking for something similar to the open file dialog in VB, except for SQL servers, where it will list all the servers available on the network and let the users select one, then enter credentials.
Does such a thing exist?
Thanks!
It should be easy to develop a dialog box similar to one SQL Server Management Studio uses. Be aware that all instances on the network cannot be enumerated because broadcast packets are not typically routed and due to firewalls so you'll need to allow the user to enter a server name in the combobox. Here's a code snippet to return a DataTable of the found instances (http://msdn.microsoft.com/en-us/library/a6t1z9x2(v=vs.110).aspx):
Dim dt As DataTable = System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources
Below is a screenshot of the login dialog from SSMS. Just populate the server name combobox with the server and instance names from the data table, and add the other needed controls.

How can I properly link my SQL Server database to an Access form and distribute it to the network and have them input information?

When I link the Microsoft Access to SQL Server locally, everything works. The second I go to a computer that is on the network, I am not able to open the form I created on the Access database.
I found out that if I open the link, I will get an error. If I choose where the DB through configurations in Access, I get the error again. If I try this a third time, it connects to the database and it is fully linked--I am able to type data into Access and it will store it in the SQL Server database as well.
My question is: How do I get it to connect to the server on the first try? I have to hit "connect" three times which takes about 5 minutes to log in. That isn't very efficient when the people using this program nothing about computers.
Linking Access to SQL Server uses ODBC. Make sure your ODBC settings are correct.

Resources