.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how to get old/new guid of a row?

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :Sql Server

Greetings ,,,

i have read about guid recently and i found that it helps to find the version of a row

now lets say i have a row with columns     empID,,EmpName

and a row    1,hatem

if that row is updated then we will have a new version of this row ,,so it will have 2 GUIDs old & New

i want to make a trigger on that table when updated it takes the value of Old and New Guid and insert it in new table called (UpdatedGuidsTable) ,,with columns Old Guid,,New Guid



any suggestion will be highly apperciated





View Complete Post

More Related Resource Links

Error: Encountered multiple versions of the same assembly with GUID...try pre-importing...TlbImp


Hi!  Can someone tell me how I can troubleshoot the following error: "Encountered multiple versions of the same assembly with GUID...try pre-importing one of these assemblies".

The website developed in VS 2010 (.Net 3.5). This error is only received on my workstation.  Another person developing the site does not experience this issue at all.  Also, not sure if this matters, but on my workstation the 'Assembly Information...' dialog contains no values even though the 'AssemblyInfo.vb' file does specify values for the title, desc, etc.  The GUID being referenced in the error is the main project of the three projects within the solution.

I tried looking through the GAC, but do not see any references to the projects or DLLs in the VS solution and am not sure what else/where to look.

If I delete the copy of the solution on my local machine and pull down a copy from source control (AnkhSVN) the solution will build with no error.  Once I make any changes, such as adding a new aspx file, then the error is received.

I can provide any additional information needed.

Want to create Page URL rewrite based on Users GUID and Display name?



I am using the asp.net membership. 

On my site I have a Profile.aspx page.

In the code behind of this page,  i get the logged in UserId (Guid) and pass

this to a method in my DAL. GetUserByUserId()


In my database I have a Table called Member which the method gets the data from

and displays details on the page about  the user.


What I want to happen is when they have logged in and are diverted to Profile.aspx,

the page URL shows www.MyWebSite/Profile/UsersName 

for example



is this possible. In my Member table I have FirstName and LastName columns or do I get the

name from the membership table.


even better would be they go straight to www.MyWebsite/JohnSmith.aspx


thank you for any help






Failed to convert parameter value from a String to a Guid.


I am trying to get the UserRole from the logged in user and send it to the database table my code is:

SqlParameter FamilyFriendsOther = new SqlParameter("@Role", SqlDbType.UniqueIdentifier);
        string [] roles = System.Web.Security.Roles.GetRolesForUser();
        if (roles.Length > 0)
            FamilyFriendsOther.Value = roles[0];

Gridview, guid ID, and Location


Presently I have a gridview, I'm in the process of populating the gridview. One colunm "Location" is displayed as the guid ID.  I need for that colunm to be displayed as the location. Here some of the code to display the grid.

myObject orgs = new myObject();
grid.DataSource = orgs;


orgs gets a list of organizations (locations) for the grid. How can I replace the guid ID with it location. Yes the guid ID and location are in a table.

return GUID

Hi,I am using LINQ.I have 2 methods.Method 1public Guid getUserIDByProfileCode(string pCode) { var user = from p in dc.OtherProfiles where p.ProfileCode == pCode select p.UserId; return user.FirstOrDefault(); }Method 2 public Guid getStudentUserId(int id) { var stdID = from p in dc.StudentProfiles where p.ID == id select p.UserId; return stdID.FirstOrDefault(); }The first method is ok. But the second method says "Can not implicitly convert System.GUID? to System.GUID. An explicit conversion exists (Are you missing a cast?)"What is the difference between these 2 mehtods?? how can I solve it?Error 2 Cannot implicitly convert type 'System.Guid?' to 'System.Guid'. An explicit conversion exists (are you missing a cast?) C:\WebDevelopment\DrivingSchool\DrivingSchool\BLL\RegistrationBLL.cs 150 20 DrivingSchool

ComboBox with Name and Guid

I have a simple question.  I am trying to store a Name and a Guid inside a combobox but it only lets me store one string value.  Is there any way to store the guid value along with the Name?  I need the guid because sometimes the name will be the same.  If not what would be the best way to approach this?   Thanks,

How to: Deal with UniqueIdentifiers, casting it to Guid in DAL

HelloMy users table has a column which is a unique identifier (basically this has FK relationship with aspnet_users table, of membership) Now I have an AppUser class which maps to my users tableuserid        intuser_aspnet_id  guid In my DAL, I am retreiving a user from the db an want to populate my appUser obj. How do i Convert value retreived to GuidappUsr.UserID = Convert.ToInt32(reader["user_id"]);appUsr.AspNetUserID =  reader["aspnet_user_id"];(There is no convert.ToGuid)How can this be done?appUsr.UserID = Convert.ToInt32(reader["user_id"]);                 appUsr.AspNetUserID = (Guid)reader["aspnet_user_id"];

Problem with Parameters.AddWithValue and GUID

Hi,have a problem, when i want to update a line in my database with the SQLCommand. I have following code: SqlCommand tmp_sqlcmd = new SqlCommand("UPDATE LogSend SET LogSend = @State WHERE DEVICE_UID = @Device_ID", Default_Con); tmp_sqlcmd.Parameters.AddWithValue("@State", logsend.state); tmp_sqlcmd.Parameters.AddWithValue("@Device_ID", logsend.Device_ID); int test = tmp_sqlcmd.ExecuteNonQuery(); tmp_sqlcmd.ExecuteNonQuery();But nothing happens when the command is executed. Any ideas?When i manually edit the line with:UPDATE LogSend SET LogSend = 1 WHERE DEVICE_UID = '5d8f3da0-e7c9-4a99-bb3f-246ce63ceebb'It works.Any ideas for me?Sincerely,Steven

Guid issue

Hi,I have aproblem with my guid validation - something extremely obvious and easy to work round, but just wondered why this brings up a syntax error.Guid Validator public static bool IsGuid(string candidate, out Guid value) { Regex guid = new Regex(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$"); bool isValid = false; value = Guid.Empty; if (candidate != null) { if (guid.IsMatch(candidate)) { value = new Guid(candidate); isValid = true; } } return isValid; } Code calling validator Guid identity; bool identityGuid = utRe.IsGuid(arrArg[2], identity);The synrax error gices me the standard "The best overloaded method..."arrArg[2] is a string btw.??? - anyone shed some light?

Guid. Can be auto generated?

Hello, I have the following table: CREATE TABLE [dbo].[Profiles] ( Id INT IDENTITY (1, 1) NOT NULL, Curriculum VARBINARY (MAX) FILESTREAM NULL, [Key] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE ) FILESTREAM_ON STORAGE The column KEY must exist because I am using a FileStream. So I need to have this column to be unique, correct? But is it possible to be auto generated instead of the need to create the value in my C# code? I mean, in this case I don't have any need to define its value in my C# code. Thank You, Miguel

Unable to cast object of type 'System.Guid' to type 'System.String'.

protected void Button1_Click(object sender, EventArgs e) { using (BurnbetDataContext dc = new BurnbetDataContext()) { var q = (from c in dc.GetTable<tbl_Payment>() where c.ID == 5 select c).Single<tbl_Payment>(); dc.GetTable<tbl_Payment>().DeleteOnSubmit(q); dc.SubmitChanges(); } } }System.InvalidCastException was unhandled by user code  Message=Unable to cast object of type 'System.Guid' to type 'System.String'.  Source=System.Data.Linq  StackTrace:       at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)       at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)       at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)&nb

cannot be applied to operands of type 'string' and 'System.Guid'

MembershipUser myObject = Membership.GetUser(); string UserID = myObject.ProviderUserKey.ToString(); BurnbetDataContext db = new BurnbetDataContext(); var creditcard = from c in db.tbl_Payments where UserID == c.UserId select c; Column UserId = uniqueidentifier Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0019: Operator '==' cannot be applied to operands of type 'string' and 'System.Guid'Source Error: Line 93: Line 94: var creditcard = from c in db.tbl_Payments Line 95: where UserID == c.UserId Line 96: select c; Line 97: Please help!

A GUID might be prepended to the filename of the log file



Problem Definition:

I have an asp.net application when i am using microsft enterprise library for logging v4.1.

I found that a guid is added to the name of my file. I did googling and came to know that because of the following reasons it  is happening:

A RollingFileTraceListener instance "owns" the log file it is writing to and locks it for exclusive write access when it writes the first log entry. It keeps the file locked until the instance is disposed. If another RollingFileTraceListener  instance is created that points to the same file, before the first instance is disposed, the second instance cannot open this file for writing and will write to a new file with a GUID prepended to its name.

So my question is how i can overcome this issue?

Please do reply. Thanks in advance.

Logging Application Block -- A GUID might be prepended to the filename of the log file



Here is my problem definintion.

I am using Microsoft.Practices.EnterpriseLibrary.Logging.dll 4.1 version. It is found that

"A GUID might be prepended to the filename of the log file".

I did some googling and came to know that this is known issue from the following link


So how to resolve this. Is there any cleaner approch that i can use.

Please do reply.

Thanks in advance.

TTP could not register URL http://+:80/Temporary_Listen_Addresses//because TCP port 80 is bein



I've a problem in WCF Duplex Contract.

I created a WCF service with wsDualHTTP Binding and hosted it by Self Hosting method.  Now my service is running as a window service.  And i refer service url in my client windows application and i tested everything is work fine, when i do all this stuff in a my local box and in LAN inside my lab.

Now the problem is i deployed this service and client application in "Citrix" box.  And i created 3 more session and i tried to access my WCF service, i got following error

"HTTP could not register URL http://+:80/Temporary_Listen_Addresses/<guid>/because TCP port 80 is being used by another application......."

I googled and i got the following link for reference "http://social.msdn.microsoft.com/forums/en-US/wcf/thread/3baf3142-63a0-4df6-bade-ea91cb477c1a/"

I added "ClientBaseAddress" inside the  Binding tag in both "service and client" (http://localhost:8001/WcfTestBridge/service).  Now i tested with one session with Citrix box.  Its worked fine.


Then i created one more session i tried to access wcf service, i got exception like ""HTTP could not register URL http://



If I use the system.guid not works. If I use system.string works.

My code works:

public bool DeleteProduct(int Id, string UserId)

       // Guid UserId = Guid.NewGuid();

        int rowsAffected = Adapter.Delete(Id,UserId);

        // Return true if precisely one row was deleted, otherwise false
        return rowsAffected == 1;

  My code not works:

public bool DeleteProduct(int Id)

        Guid UserId = Guid.NewGuid();

        int rowsAffected = Adapter.Delete(Id, UserId);

        // Return true if precisely one row was deleted, otherwise false
        return rowsAffected == 1;

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1502: The best

How To Map A GUID Variable And Use It In An OLE DB Source Data Flow Select Query


I have a simple SSIS package that does the following. 

On the control flow tab, there is an Execute SQL task that calls a stored procedure and returns a GUID. 

I have a package scoped variable that stores a UNIQUEIDENTIFIER output from the stored procedure. It appears that the package variable data type does not include a GUID data type so I tried to use string instead.

Next, the Execute SQL task is mapped to a data flow task. 
Within that data flow task I have an OLE DB Source which connects to a SQL Server Destination task.

On the OLE DB Source Editor screen I have a query that performs the following:

SELECT ID, SessionKey, ....
FROM dba_DroppedLoginsLog
WHERE SessionKey = ?

I have clicked on the parameters button to map the Parameter to my variable called User::SessionKey. This is the output variable from my Execute SQL Task component on the Control Flow tab. This value should be a GUID, but again, I don't see a data type for that.

When I execute the package it fails on the OLE DB Source with the following error:
[OLE DB Source [1908]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE D
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend