Im trying to connect to a database and then feed the data into a binding source that then is displayed in a datagridview that i can filter information out of.
with that said. when i run trial querys in excel I get a sql statment like this
SELECT gci_requests.ref_num, gci_requests.summary, gci_requests.open_date, gci_requests.resolve_date, gci_requests.category_name, gci_requests.group_name, gci_requests.status_name, gci_requests.customer_adaccount, gci_requests.customer_lastname, gci_requests.customer_phone, gci_requests.reportedby_adaccount, gci_requests.assignee_adaccount
FROM mdb_rpt.dbo.gci_requests gci_requests
WHERE (gci_requests.category_name Like '%Publishing USAT%')
My question do i use the FROM part in my connection string or is that something else all together?
If you're connecting to SQL Server then I strongly suggest that you use SqlClient rather than Odbc.
That connection string is incorrect. The "Server" part of connection string is the name of the SQL Server instance you want to connect to. If you want to specify a database name too then that goes in a separate property of the connection string. For SqlClient its "Data Source" but I'm not sure for Odbc. The FROM part of your query is specifying the table to retrieve data from. The connection string cares nothing for tables.
If you are pulling from one table then you do not need to use the table name with the field name as well. This is not an issue but makes it more easily readable.
The Data Source is the server and instance name. The Initial Catalog is the name of the database.
You're probably getting confused because of the loose terminology people generally use. People will call SQL Server a "database" but it's actually an RDBMS, i.e. a system that manages relational databases. Each installation of SQL Server manages multiple databases.
In the attached image my Data Source would be "Serenity\SQL2000" and my Initial Catalog would be "RMSSample". Serenity is the name of the physical server on which SQL Server is installed and its a named instance called SQL2000. I have two other instances on the same server named SQL2005 and SQLExpress. This instance manages all the databases listed. The user name and password you provide are for the SQL Server instance, then you can connect to any database within that instance.
Last edited by jmcilhinney; Mar 14th, 2007 at 06:16 PM.