none
ServerVersion_'objcon.ServerVersion' threw an exception of type 'System.InvalidOperationException'_string {System.InvalidOperationException} Soon after I execute the line OleDbConnection objcon = new OleDbConnection("Provider=SQLOLEDB.1;Integrated Secur RRS feed

  • Question

  • Soon after I execute the line

    OleDbConnection objcon = new OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Context Connection=true;Initial Catalog=XXXXX;Data Source=XXXXXX");

    I am able to connect from SQL server IDE, any of the datasources using the wizards but not from the code. The wired thing is I can connect to my local database but not a single server on the network using the code, but through IDE or any of the datasource dataset wizards I am able to connect. 

    Wednesday, July 27, 2016 2:52 PM

All replies

  • What network are you talking about? And is  MS SQL Server running on a machine on this network even configured to allow remote connections to it?
    Wednesday, July 27, 2016 6:47 PM
  • Hi Shaheryar Arshad,

    Thank you for posting here.

    The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Since your issue is related to ado.net dataset forum. I will move the thread to that forum for better support.

    If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Best Regards,

    Hart


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Thursday, July 28, 2016 7:02 AM
  • First, if you're access SQL Server, you should be using the SqlConnection object, not the OleDbConnection. I have written a blog post that shows you how to easily find the correct Connection string to use:

    http://geek-goddess-bonnie.blogspot.com/2015/02/easy-peasy-connection-strings.html

    But, I suspect that your problem with accessing the remote SQL Server is that you shouldn't be using Integrated Security for that, but should be using user id/password instead.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, July 30, 2016 3:59 PM