Re: Get Primary Key from Table.



Hi,

tried it now. The same Result. As I see it Unique != Primary Key.
Unique allows Null Values, Primary Not. Nevertheless I found no
function to extract the neccessary information.

Thanks,

Stefan

public Boolean isPrimary(int checkPos)
{

DataTable mySchema =
getConnectionPtr().GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new
Object[] { null, null, null, "Table" });
return mySchema.Columns[checkPos].Unique;
}

On 14 Feb., 11:42, "Miha Markic [MVP C#]" <miha at rthand com> wrote:
Hi,

I would rather use GetOleDbSchemaTable method.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & developmentwww.rthand.com
Blog:http://cs.rthand.com/blogs/blog_with_righthand/

"_MC_" <m...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message

news:1171440313.891401.166990@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi,

I want to request if an Colum is Primary Key or Not via Ole (C# Code).
Following Part of Code descripes my ideas. However the function
returns always false, no matter what Database System (e. g. MS SQL,
Paradox, ...). This also appears if i request the Attribute
'AllowDBNull'. Now - how can I fix this?

Thanks for your help.

Stefan

Code:

public Boolean isPrimary (int checkPos)
{
OleDbDataAdapter myAdapter = new
OleDbDataAdapter(commandText, conn);
DataSet mySet = new DataSet();

myAdapter.Fill(mySet);

return mySet.Tables[0].Columns[checkPos].Unique;
}


.



Relevant Pages

  • Re: Sorting w/Primary Key
    ... >is the primary key, and extract only items based on ... Put Ascending on the Sort row for N and for M. ... specified range of values on the first field; ...
    (microsoft.public.access.tablesdbdesign)
  • Relational Algebra Expression
    ... I've been trying to figure out how to use relational algebra to ... <Year, Name, Votes> ... where the primary key is Year+Name (composite ... What I'm trying to do is extract all the years where we have more than ...
    (comp.databases.theory)
  • Re: Relational Algebra Expression
    ... I've been trying to figure out how to use relational algebra to ... <Year, Name, Votes> ... where the primary key is Year+Name (composite ... What I'm trying to do is extract all the years where we have more than ...
    (comp.databases.theory)
  • Re: Import Spreadsheet Wizard
    ... Importing or linking a file? ... MVP - Technologies Virtual-PC ... You note that the spreadsheet has a primary key column in it. ...
    (microsoft.public.access.externaldata)
  • Re: Append Query Key Violation
    ... "Ken Snell (MVP)" wrote: ... related back to the primary key in tblContactsV1? ... I want to append record from tblContactsV1 to tblPatientV1. ...
    (microsoft.public.access.queries)