Re: Q: GUID

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Greg Burns (greg_burns_at_DONT_SPAM_ME_hotmail.com)
Date: 08/05/04


Date: Thu, 5 Aug 2004 14:54:40 -0400

Since it is Access, you will not be able to use the uniqueidentifier data
type. You also won't be able to use the NEWGUID() function. Those are both
SQL server specific.

My Access exposure is limited to 97 version. Do the newer version have
better support for GUIDs?

I see in 97 that you can use an Access datatype autonumber and change the
field size to "Replication ID". It seems to be making GUIDs.
Unfortunately, I have no idea how to make such a beast using DDL.

Greg

"Geoff Jones" <geoff@NODAMNSPAM.com> wrote in message
news:41127b63$0$22008$cc9e4d1f@news.dial.pipex.com...
> Hi Greg
>
> I've been given a project which a colleague was working on. This isn't my
> field!!! Still, it is nice to learn something new.
>
> This is an Access database project. I'm trying to create a new database
"on
> the fly" with the primary key set to a GUID. I would have thought this an
> easy thing to do - obviously, I am very wrong :)
>
> Geoff
>
> "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
> news:O9xSGRxeEHA.3028@TK2MSFTNGP12.phx.gbl...
> > I need more info. For being a newbie you are attempting stuff I've
never
> > had to do in code before. :^)
> >
> > I see you are using oledb, which implies to me that you are not using
SQL
> > server. (If you're not, then all this talk of uniqueidentifiers isn't
> gonna
> > fly). If this is an Access database, I don't think you can issue the
same
> > DDL (data denition language) SQL statements as you would for SQL server.
> >
> > If it is SQL (then I would start using the SqlClient's SqlCommand
object),
> > then I think you have to issue to a second cmd.ExecuteNonQuery after you
> > create the table with the first command. The second command should be
> > similar to this (assuming your key field is named "book_id"):
> >
> > ALTER TABLE [dbo].[books] ADD
> > CONSTRAINT [DF_books_book_id_quid] DEFAULT (newid()) FOR [book_id],
> > CONSTRAINT [PK_books] PRIMARY KEY CLUSTERED
> > (
> > [book_id]
> > ) ON [PRIMARY]
> >
> > What are you trying to accomplish, why do you need to make your table on
> the
> > fly?
> >
> > Greg
> >
> >
> > "Geoff Jones" <geoff@NODAMNSPAM.com> wrote in message
> > news:41126a9e$0$21963$cc9e4d1f@news.dial.pipex.com...
> > > Hi Greg
> > >
> > > Sorry, but I'm a real Newbie to all this and I don't know how to set a
> > > default :(
> > >
> > > Could you show me in the code example I gave?
> > >
> > > Many thanks in advance
> > >
> > > Geoff
> > >
> > > P.S. And sorry for being so dim!!!!!!
> > >
> > > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
> > > news:ul8uRpweEHA.2044@TK2MSFTNGP10.phx.gbl...
> > > > You need to set a default of NEWGUID(), or it won't "autonumber"
like
> an
> > > > identity field.
> > > >
> > > > Greg
> > > >
> > > > "Geoff Jones" <geoff@NODAMNSPAM.com> wrote in message
> > > > news:41125afc$0$21970$cc9e4d1f@news.dial.pipex.com...
> > > > > Hi Chris
> > > > >
> > > > > Like this you mean?
> > > > >
> > > > > Dim databaseCommand As OleDbCommand = New OleDbCommand("CREATE
TABLE
> > > books
> > > > > (" ID UNIQUEIDENITFIER, Book VARCHAR(50), CONSTRAINT [pk_ID]
PRIMARY
> > KEY
> > > > > (ID))",
> > > > > myDatabaseConnection)
> > > > >
> > > > > Geoff
> > > > >
> > > > > "Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net">
wrote
> > in
> > > > > message news:1cc1ndnwayvs3.18c6wve3d566i$.dlg@40tude.net...
> > > > > > On Thu, 5 Aug 2004 11:59:44 +0100, Geoff Jones wrote:
> > > > > >
> > > > > > > That is, using the following code, I can set an integer
primary
> > key,
> > > > but
> > > > > how
> > > > > > > do I change it to a GUID?
> > > > > > >
> > > > > >
> > > > > > Make your column type a UNIQUEIDENITFIER type
> > > > > >
> > > > > > --
> > > > > > Chris
> > > > > >
> > > > > > dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
> > > > > >
> > > > > > To send me an E-mail, remove the "[", "]", underscores
,lunchmeat,
> > and
> > > > > > replace certain words in my E-Mail address.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Q: GUID
    ... > I see you are using oledb, which implies to me that you are not using SQL ... If this is an Access database, I don't think you can issue the same ... > create the table with the first command. ... >> Hi Greg ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Showing dataset data on Crystal Report
    ... Greg ... >>I have been trying to display dataset data in a Crystal Report in a ... >> default xtreme.mdb Access database was no problem, ... >> display data from an SQL 2000 database, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Changing Document / Live Document?
    ... Access database with a memo field to be merged into a word document. ... Regards, ... Greg Strong ...
    (microsoft.public.word.mailmerge.fields)
  • Changing Document / Live Document?
    ... Access database with a memo field to be merged into a word document. ... Regards, ... Greg Strong ...
    (microsoft.public.word.pagelayout)
  • Changing Document / Live Document?
    ... Access database with a memo field to be merged into a word document. ... Regards, ... Greg Strong ...
    (microsoft.public.word.formatting.longdocs)