In C# 

Guid myGuid = new Guid.NewGuid();  

 

This will give you a value in your myGuid instead of 00000-0000-0000-000000
with Guid myOtherGuid = new Guid();

 

The Guid is your friend for your identifiers.  I use to think that int with
an auto increment was fine but NOOOOOOOOOO!  When your movide meta data
between dev, test, stage and prod that int will bite you!  The GUID never
will.   

 

.........................

Stephen Russell - 

Senior Visual Studio Developer, DBA

 

Memphis, TN

901.246-0159

 

 

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Jon Liu
Sent: Saturday, November 22, 2008 9:04 AM
To: [email protected]
Subject: [DotNetDevelopment] Re: Image Upload

 

Stephen,

Thanks for the reply,  I realize that this functionality might not be needed
since in all reality the user probably won't upload hte same image..but I
just wanted to build it in as this is my second application using .NET and I
wanted to get a feel for everything.

Also, this is a totally noob question and yes I have tried searching it, but
how do you create a GUID?  Any suggestions for reference tools?

Thanks

Jon

On Sat, Nov 22, 2008 at 6:53 AM, Jon Liu <[EMAIL PROTECTED]> wrote:

Thanks for the quick reply.  It looks like you're using VB.NET.    I'm using
C#...off topic, but is there anyway to create a stored procedure in C# using
the actual Stored Procedure features under Database Explorer, of does it
have to be done in the .cs file?  The reason I ask is because I already have
my connection to the table established using the SqlDataSource control as
well as connection string defined in the config file, and it would be much
easier to just define the query and conditions in the Database Explorer
version as opposed to typing it all out in C#.....

If so/if not, does anyone know any good reference tools for creating stored
procedures with SQL and C#?  Thanks.

Jon 





On Sat, Nov 22, 2008 at 6:43 AM, Stephen Russell <[EMAIL PROTECTED]>
wrote:


You could just put the month/date as an appendage instead of a counter.  Or
just the Second of the time stamp.

In all reality how many times would a filename be uploaded?

You might consider breaking down the container for holding the files into
sub folders.  This way the same camera file name won't be consistent in a
sub folder.

I never run into this issue because I organize the holding folder(s).  I use
GUIDs for the primary key of the table.  I then break the guid along breaks
of every dash -.  So
d5348cfb-e077-45d2-9254-231076ead3b8  would look like this:
\d5348cfb\e077\  I will now have maybe 2 files in this folder, usually only
1.

I made the GUID at receipt of file, I then declare if folder exists or not.
Make if needed and then use that path for the path section of my file table.
This way the USERS property never changes names according to them.  I have a
time date stamp in the table as well so the user would be shown the most
recent version of their file if that was important to them.


.........................
Stephen Russell -
Senior Visual Studio Developer, DBA

Memphis, TN
901.246-0159




-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of BigJ
Sent: Friday, November 21, 2008 10:19 PM
To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting
Subject: [DotNetDevelopment] Image Upload


I'm using the FileUpload control to upload images to my image folder,
storing the pathway to the image in table.  My primary key is the
imagePath column  My question is, how do you detect if an image
already exists in the table, and if so how to alter the name like
image/mypic.jpg and image/mpic(2).jpg , so on and so forth.

I came up with the initial idea of adding an imageCnt column
(equivalent of a counter) using the SqlDataSource control to get the
latest version of the image like so:

       SelectCommand="SELECT MAX(ImageCnt) FROM userImages WHERE
ImagePath LIKE @ImagePath"

I was going to then the result of that to decide what number to append
to the image.  However the problem is how do I grab that ImageCnt
value before the insert action is attempted?  Any insight is
appreciated...thanks.

Thanks

Jon

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.175 / Virus Database: 270.9.9/1802 - Release Date: 11/21/2008
9:37 AM



 

 

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.175 / Virus Database: 270.9.9/1802 - Release Date: 11/21/2008
9:37 AM

Reply via email to