YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

C# connect with OLEDB to PI system Options · View
buntux
#1 Posted : Tuesday, September 13, 2011 10:06:07 AM
Rank: Newbie
Groups: Member

Joined: 9/13/2011
Posts: 3
Hi,

I am unable to connect using this code below:

Code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            OleDbConnection DBPIConn;
            DBPIConn = new OleDbConnection();
            DBPIConn.ConnectionString = "Provider=PIOLEDB.1;Data Source=SERVER NAME;Persist Security Info=True;Password=PASSWD;User ID=LOGIN";
            DBPIConn.Open();
            DBPIConn.Close();
        }
    }
}


I installed PI SDK 1.3.8 patched to 1.3.8.391 and OLEDB 3.3.0.1a (plus prerequisites of course).
The error is very strange: wrong username and password:
Code:

System.Data.OleDb.OleDbException was unhandled
  Message="[PI SDK] Unable to open a session on a server.  The user name and password may be incorrect.  SERVER NAME"
  Source="PIOLEDB"
  ErrorCode=-2147467259
  StackTrace:
       at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()
       at ConsoleApplication1.Program.Main(String[] args) in C:\Documents and Settings\buntux\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs:line 15
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


When I manually input the user name and password using for example SDK Connection functionality I log into PI system without any issues.

Do I have to add some reference to my C# code which I wrote in VS 2k5 or maybe I need to install something more?

Thank you for your help in advance.
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
buntux
#2 Posted : Wednesday, September 28, 2011 10:06:06 AM
Rank: Newbie
Groups: Member

Joined: 9/13/2011
Posts: 3
I found mistake in my code: I switched password with login name.
Stupid but true.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.