Question Failed to open a connection to the database

G4ThuNiJohn

New member
Joined
Sep 14, 2017
Messages
2
Programming Experience
1-3
Hai,

While trying to open the datasource from datagrid view I ' getting the follwing message

"Failed to open a connetcion to the database

This server version is not supported. Only servers up to sql 2005 is supported."



I am getting this message after changing the sql from 2005 to 2012.
 
Firstly, please don't post the same question multiple times. I have deleted your other thread on this topic.

Secondly, you're not opening a database connection from a DataGridView. A grid control will display data but that's all. It has nothing to do with where the data comes from. That is a completely separate operation.

As for the question, I'm not sure what part of the error message is unclear. It states outright that nothing later than SQL Server 2005 is supported and you stated that you are using a later version. Your profile says that you are using .NET 3.0 so, while I wasn't aware of it being the case, maybe you can't connect to later than SQL Server 2005 because of that. That would mean upgrading your app to a later version of .NET. That would be the first thing I'd test. If that doesn't sort the issue then you should post back with ALL the relevant information, which would include the code you're actually using to connect.
 
Firstly, please don't post the same question multiple times. I have deleted your other thread on this topic.

Secondly, you're not opening a database connection from a DataGridView. A grid control will display data but that's all. It has nothing to do with where the data comes from. That is a completely separate operation.

As for the question, I'm not sure what part of the error message is unclear. It states outright that nothing later than SQL Server 2005 is supported and you stated that you are using a later version. Your profile says that you are using .NET 3.0 so, while I wasn't aware of it being the case, maybe you can't connect to later than SQL Server 2005 because of that. That would mean upgrading your app to a later version of .NET. That would be the first thing I'd test. If that doesn't sort the issue then you should post back with ALL the relevant information, which would include the code you're actually using to connect.


When i right click the datagridview there is a datasource property .If i want to add a table in the datagridview i am getting the above message
 
When i right click the datagridview there is a datasource property .If i want to add a table in the datagridview i am getting the above message

That means that the grid is bound to a DataTable that is part of a DataSet. The grid knows nothing about how the data gets into that DataTable. The connection is made by a table adapter. You call Fill on the table adapter and pass it the DataTable. It opens a connection to the database, executes a query and populates the DataTable with the result set. Nothing to do with the grid. The designer will generate much of the code to create and use these objects for you for convenience but they are still separate objects that are simply used together because it's useful to do so.

So, it appears that you have a typed DataSet, which you can see listed in the Solution Explorer. If you double-click that then it will open in the designer and you can see all the DataTables and table adapters. Within each table adapter, buried a few layers deep, will be a SqlConnection object. As I said, I was not aware that it was the case but perhaps that object doesn't support later than SQL Server 2005 in .NET 3.0. Note that .NET 3.0 and 3.5 are just extensions to .NET 2.0 and that's where the SqlConnection object comes from. Maybe you will need to update to at least .NET 4.0 to support SQL Server 2012. This is just an educated guess on my part but, if it is the case, there will be documentation somewhere specifying that limitation that you could find with some research.
 
Back
Top