Accessing UniData through .net

1.6k views Asked by At

I'm having trouble with accessing UniData data from the u2.net toolkit. I'm able to connect ok - have tested connections with the "Test Connection Tool" and in code, both connections work fine. My problem is when I try and fill a dataset - using the sample code: I get this error:

[U2][UCINET][UNIDATA]:You have no privilege on file THENAME

Here is the code:

           U2Connection con = new U2Connection();
        try
        {
            U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
            conn_str.UserID = "id";
            conn_str.Password = "pwd";
            conn_str.Server = "srv2";
            conn_str.Database = "DB.XXX";
            conn_str.ServerType = "UNIDATA";
            conn_str.RpcServiceType = "udserver";


            con.ConnectionString = conn_str.ToString();
            con.Open();
            DataTable schema = con.GetSchema();
            U2DataAdapter da = new U2DataAdapter("SELECT * FROM THENAME ", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
        }
        catch (Exception ex)
        {
            string lStr = ex.Message;
        }
        finally
        {
            con.Close(); 

1 more note, I have an ODBC connection setup. Through ODBC I can use the same credentials inside a SQL Server Linked Server to access the same query successfully. Any Ideas would be appreciated.

2

There are 2 answers

2
Dan McGrath On

By default, UniData grants no privileges to access files via SQL.

You will need to run CONVERT.SQL from the database to grant privileges to the file.

You can find out more about the command by either running HELP CONVERT.SQL on the command line, or reading the manuals.

0
Rajan Kumar On

Could you please run TCL command ?

select * from privilege;

Do you see THENAME there? For example, see enclosed screen shot for VOC file.

enter image description here

enter image description here