Forum Discussion

hshams's avatar
hshams
Occasional Contributor
9 years ago

sql server connection error "Provider cannot be found. It may not be properly installed."

Hi,

 

I am trying to connect to the sql server db using TestComplete 11, but I am getting an error: "Provider cannot be found. It may not be properly installed."

Below is the code I am using, please let me know how can I fix it.

 

 

 

AConnection = ADO.CreateADOConnection();

// Specify the connection string

AConnection.ConnectionString = "Provider=System.Data.SqlClient;"+

"data source=192.168.202.40\mssqlserver01,1724;initial catalog=K212.HrPayroll.ThamesValley.Hina;persist security info=True;user id=sql.server;password=sql.server";

 

// Suppress the login dialog box

AConnection.LoginPrompt = false;

AConnection.Open();

// Execute a simple query

RecSet = AConnection.Execute_("SELECT * FROM EC_GROUP WHERE EMP_GROUP_CODE = 'ADMIN1'");

// Iterate through query results and insert data into the test log

RecSet.MoveFirst();

while(! RecSet.EOF)

{

Log.Message(RecSet.Fields.Item("EC_GROUP").Value, RecSet.Fields.Item("EMP_GROUP_CODE").Value);

RecSet.MoveNext();

}

AConnection.Close();

}

 

 

 

Thanks,

Hina

 

    • hshams's avatar
      hshams
      Occasional Contributor

      I already have ODBC driver added for SQL Server. Please see the screenshot.

  • NisHera's avatar
    NisHera
    Valued Contributor

    I think you are using a wrong connection string....

    according to this you are using .NET framework data provider....TC is not running on .NET

    You have to use ODBC driver specified here

     

    for eg I'm using 

        sConnectionString = 'Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=';
        sConnectionString = sConnectionString + sDatabaseName;
        sConnectionString = sConnectionString + ';Data Source=' + sSQLServerName;
    • hshams's avatar
      hshams
      Occasional Contributor

      I have added the ODBC Driver, you can look at the screenshot.

      Below is the connection string I am using, I am still getting the same error.

       

      var AConnection = ADO.CreateADOConnection();

      AConnection.ConnectionString = "Provider=SQLDriver; Server = KEOUS-SQL\MSSQLSERVER01,1724; Database=K212.HrPayroll.ThamesValley.Hina;user id = sql.server;password=sql.server";

       

       

       

       

      • Kostja's avatar
        Kostja
        Contributor

        Not sure if it might help you, but...

         

        I am using the newer ODBC driver for oracle and my connection strings looks like this:

         

        var Cmd = ADO.CreateADOCommand();
        Cmd.ConnectionString = "Driver={Oracle in instantclient_12_1};Dbq=dbq;Uid=uid;Pwd=pwd;";

         

        For Dbq i use the database configured in System DNS.