Re: Get Primary Key from Table.
- From: "_MC_" <mc@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 14 Feb 2007 04:29:15 -0800
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;
}
.
- Follow-Ups:
- Re: Get Primary Key from Table.
- From: _MC_
- Re: Get Primary Key from Table.
- References:
- Get Primary Key from Table.
- From: _MC_
- Re: Get Primary Key from Table.
- From: Miha Markic [MVP C#]
- Get Primary Key from Table.
- Prev by Date: Re: updating database views via tableadapter?
- Next by Date: Re: Get Primary Key from Table.
- Previous by thread: Re: Get Primary Key from Table.
- Next by thread: Re: Get Primary Key from Table.
- Index(es):
Relevant Pages
|