Hello Rohit,
Thank you for the reply. First, you are correct, it is LocalDB (I must have deleted the o in my post).
I had tried and tried your solution again (making sure to change the LcalDB to LocalDB). I had:
connection =
OpenSQLConnection[
JDBC["Microsoft SQL Server(microsoft)", "(LocalDB)\\MSSQLLocalDB"],
"Catalog" -> "StockDataDB", "instance" -> "LOCALDB#B5C431B2"]
but I received the error:
JDBC::error: The connection to the host (LocalDB), named instance MSSQLLocalDB failed. Error: "java.net.UnknownHostException: (LocalDB)". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.
I am trying to make sense of all this. I tried the expression you provided and received the error.
What I am trying to understand is this:
1) I created the database by using Microsoft SQL Server Management Studio and called it StockDataDB,
2) I then ran a script in MSSMS to create one table called StockDataTable to hold the Ticker, Period, Date, Open, High, Low, Close, and Volume (the typical candlestick information)
3) Via a Windows Form Applications written in C# I read a set of CSV file that held the stock data. Those CSV files were actually created from a Mathematica program that downloaded stock data and exported them to the csv files. For instance, the daily data for IBM is stored in IBM-Day.CSV and has columns for Date, Open, High, Low, Close, and Volume.
The Windows Form Application read the CSV file and filled the StockDataTable with about 400 tickers with Daily, Weekly, and Monthly data.
4) To check that everything worked, I made a query to read some of the ticker data in the database and the data was indeed in the database. I was able to connect to the database and read the data from a Windows Forms Application in C# as well as from MSSMS
So far, fairly simple and straightforward.
What I don't seem to understand is why it is so difficult to connect to a database with Mathematica.
For instance, when I look at the documentation for SQLExecute[] and execute the expressions in the documentation notebook, everything works splendidly.
When I run the conn = OpenSQLConnection["demo"];
the connection works great and the expressions that get data or create data into the "Demo" database work perfectly.
What I also do not understand is how in the example we only need to provide the name of the database "demo" to connect. Why can't I also just run conn = OpenSQLConnection["StockDataDB"];
?
I have spent 2 days just trying to connect to a simple SQL database. All my other code is ready to go. So far, I have been reading my data from CSV files. This is far, far less than ideal as I can't make simple or complex queries.
Please, anyone, let me know what kind of information from MSSMS I need to put in my OpenSQLConnection[] function call so that I can connect.
One note: I have looked at the ODBC Data Source Administrator and I don't see a Microsoft SQL Server (microsoft) entry under the "Drivers" tab. There is just a "SQL Server" associated with SQLSRV32.DLL from 5/10/2023 in case this helps.