April 17, 2018 at 8:23 am
timwell - Tuesday, April 17, 2018 8:05 AMthierry.vandurme - Tuesday, April 17, 2018 6:18 AMThanks for sharing.
I may be wrong but I don't think any of the SqlConnection constructors throws exceptions (cfr https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.sqlconnection(v=vs.110).aspx)
So the try/catch shouldn't be necessary when creating it, only when opening the connectionBy supplying a really incorrect connection string I was able to cause an ArgumentException exception. That is why I included the try/catch for that.
It's not thrown by the constructor itself but when it's parsing the string.
If your formatting is good enough adding a try/catch for that might be more than necessary.
Cool, thanks for the feedback!
April 20, 2018 at 9:15 am
I get a red squiggly line under this statement:
using System.Data.SqlClient;
the hint says "the type or namespace SqlClient does not exist in the namespace System.Data
Tried adding references to System.Data.dll (I found a ton of them on my machine), but it doesn't seem to help
April 20, 2018 at 10:56 am
Misha_SQL - Friday, April 20, 2018 9:15 AMI get a red squiggly line under this statement:
using System.Data.SqlClient;
the hint says "the type or namespace SqlClient does not exist in the namespace System.Data
Tried adding references to System.Data.dll (I found a ton of them on my machine), but it doesn't seem to help
Jonathan AC Roberts - Friday, April 20, 2018 10:03 AMMisha_SQL
You might need to add System.Data to the project references. When you are typing it intellisence should show you the available items.
Jonathan is correct, what I have in my project references is System.Data, with the same version numbers as the System reference.
When you said you tried adding references to System.Data.dll was that in the project references (right-click references and select Add Reference) or something else?
April 20, 2018 at 11:32 am
timwell - Friday, April 20, 2018 10:56 AMMisha_SQL - Friday, April 20, 2018 9:15 AMI get a red squiggly line under this statement:
using System.Data.SqlClient;
the hint says "the type or namespace SqlClient does not exist in the namespace System.Data
Tried adding references to System.Data.dll (I found a ton of them on my machine), but it doesn't seem to helpJonathan AC Roberts - Friday, April 20, 2018 10:03 AMMisha_SQL
You might need to add System.Data to the project references. When you are typing it intellisence should show you the available items.Jonathan is correct, what I have in my project references is System.Data, with the same version numbers as the System reference.
When you said you tried adding references to System.Data.dll was that in the project references (right-click references and select Add Reference) or something else?
Thank you everybody. I think my problem was that I created a wrong type of application, so none of the default references were included. After re-creating as Console App (.NET Framework), as a the article mentions, I see a bunch of references specified including System.Data, so it's all good now. Sorry, I don't do much C#.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply