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

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

Guid. Can be auto generated?

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :Sql Server
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

View Complete Post

More Related Resource Links

Selecting the correct auto-generated ID associated with a given customer

I have the following two tables (among many) in an OLTP database: TABLE NAME: BusinessEntity TABLE FIELDS: BusinessEntityID, int, IDENTITY(1,1), NOT NULL, PRIMARY KEY BusinessEntityType, nvarchar(10), NULL TABLE NAME: Person TABLE FIELDS: BusinessEntityID, int, NOT NULL, PRIMARY KEY, FOREIGN KEY to BusinessEntity.BusinessEntityID FirstName, nvarchar(30), NULL LastName, nvarchar(30), NULL There is a 1-to-1 Identifying Relationship between the BusinessEntity and Person tables. When a new customer needs to be added to the database, I execute the following T-SQL statement: INSERT INTO BusinessEntity (BusinessEntityType) VALUES (‘Customer’); What I don’t know how to do is retrieve the value of BusinessEntity.BusinessEntityID that was automatically assigned to the new customer so I can then append it to Person.BusinessEntityID. While I know I can execute: SELECT MAX (BusinessEntityID) FROM BusinessEntity; there is no guarantee that the BusinessEntityID will be the one associated with the new customer I just added because it is possible that other new customers can be added to the BusinessEntity table by other users during the interim period between the time I execute the previously mentioned INSERT command and then SELECT command. Any help/guidance in resolving this issue would be greatly appreciated.  Thanks.

Code behinds in MVC2 - How to inject auto-generated code into views via partial classes?

Background:I have written a t4 template that basically replaces the work done by StronglyTypedResourceBuilder to give design time access to string resources as properties of classes, one class per resource file.  Why?  Well I needed to add some customer code that handles string token substitution and a few other customizations.  Anyway, the template is working out really well and I may blog on it soon.In the mean time though, following a common pattern, I have one .resx file for each view, master page, controller, etc.  I would really like my t4 template to add a property to each such entity that gives quick access the custom resource class associated with it.  For controllers this is easy.  T4MVC is ensuring that they are a all declared partial.  All I need to do is create the appropriate partial class in my output that declares a readonly property that returns an instance of the appropriate generated resource class.The Problem:I would like to do the same thing, inject generated code, into my views.  Were this traditional ASP.Net, each .aspx page would have a .aspx.cs page and possibly an .aspx.designer.cs page that are all partial classes extending in the aspx page's class definition.  There is no such thing by default in MVC and for good reason.  However, I think for my purposes, if there is a way to do this, it

InvalidOperationException using auto-generated class

I'm getting the below exception while trying to create an instance of  XmlSerializer using the class generated from XsdObjecGen. Any ideas on what may be causing this? System.InvalidOperationException: There was an error reflecting field '__ApplicationArea'. ---> System.InvalidOperationException: There was an error reflecting type 'ConsoleApplication2.Oagis.ApplicationArea'. ---> System.InvalidOperationException: There was an error reflecting field '__Sender'. ---> System.InvalidOperationException: There was an error reflecting type 'ConsoleApplication2.Oagis.Sender'. ---> System.InvalidOperationException: There was an error reflecting field '__LogicalID'. ---> System.InvalidOperationException: There was an error reflecting type 'ConsoleApplication2.Oagis.LogicalID'. ---> System.InvalidOperationException: There was an error reflecting field '__Value'. ---> System.InvalidOperationException: There was an error reflecting type 'System.String'. ---> System.InvalidOperationException: Value 'String' cannot be used for the XmlElementAttribute.DataType property. The datatype 'http://www.w3.org/2001/XMLSchema:String' is missing. The code in question from the exception.. '*********************** XmlText field *********************** <XmlText(DataType:="String"), _ EditorBrowsable(EditorBrowsableState.Advance

remove stack trace , Additional Info, from log file


i am using belowcode in web.config 

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
      <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName=".\Logs\jeejix_error.log" footer="------------Error End----------------------------" formatter="Text Formatter" header="---------Error Start-------------------------------" rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="50" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken

How to remove auto generated right blank column from the wpf datagrid?


i have already use this.


Accessing Auto-Generated Textbox in Gridview


Dear All,

 I have a gridview which has autogenerate Columns Property "TRUE", and i'm dynamically binding this gridview with columns with sql database dataset. there is no data in sql but i am successful in showing blank gridview on form, now i want textboxes in gridview attached with each column, so i wrote code in RowDataBound which generates textbox automatically and assigns ID to each textbox, nw i want to insert that data from textbox to database but i'm not getting text which is entered in those textboxes, as i am accessing that textboxes using findcontrol and passing the id like gridview1_ctl03_text0. but i''m not getting any value from textbox please help?? 

In short i want to access auto generated textbox (with out any id predefined ) values from footer of gridview ?can any one please help?

How to change the first column of auto-generated columns of a gridview.


Hi, I have a gridview which makes use of a datasource. The columns are auto-generated.

Right now, my task is to make the first column into a url column. Does anybody know how to do it?


Add "a ref" to a column in a gridview where the columns are auto-generated


 I need to make a link for all the rows in one column of a gridview(VB .Net) where the grid has been auto-created from the data source. The link would simply point to another ASP details web page. The examples I have found have all been in C# and I don't quite follow them.



My auto-generated code gives errors, can somebody see why???


I have a windowsservice and this windowsservice calls a webservice.
When I update this webservice, visual studio create a reference.cs.
The problem with this reference.cs is that is gives me more then 100 error
The error messages are all the same:
The type name 'AckService' does not exist in the type 'MyNewService.MyNewService' C:\MyNewService\Service References\AckService\Reference.cs 

Can somebody see why?

This is the code:

// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3053
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>

namespace MyNewService.AckService {
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="http://npq/AddIncident", ConfigurationName="AckService.ServiceSoap")]
    public interface ServiceSoap {
        // CODEGEN: Generating message contract since element name xmlString from namespace http://npq/Ad

auto generated keys?

which transformation ll generate auto generated ID  i mean like in informatica we use sequence generate to genreate sequence no.   please give me logic

Compiler-generated scopes for local variable declarations

I was tasked with understanding and fixing a bug on error reporting with foreach iteration variables the other day, and it got me thinking about local variable scoping rules in C# in general. First, the bug.

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.

Charset Problem with dynamically generated Word Document


in my asp.net web application i am dynamically generating a word documnet out of a sql data. I have set the char set UTF-8 during the doument creation in code but still when i open the generated document and check it char set .. it is always windows-1252 not the one that i have set. My sql data in the document have special characters whihc can only be understandable using the UTF-8 charset otherwise its always ?T written in place of an apostrophy . Pasting my code here..

         HttpContext.Current.Response.ContentType = "application/msword";
         HttpContext.Current.Response.ContentEncoding = System.Text.UnicodeEncoding.UTF8;
         HttpContext.Current.Response.Charset = "utf-8";
         string strFileName = "Details" + ".doc";
        HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
        StringBuilder strHTMLContent = new StringBuilder();
        string strMessage = " ";
        DataView abstractview = (DataView)dsAbstract.Select(DataSourceSelectArguments.Empty);
        foreach (DataRowView row1 in abstractview)
            strMessage += "<table border='1' cellspacing='0' cellpadding='5' width

BITS: Write Auto-Updating Apps with .NET and the Background Intelligent Transfer Service API


Both the .NET Framework and Windows have some very interesting APIs for creating applications that are capable of updating themselves automatically over a network. There are many advantages to writing your application to update itself like Windows Update does, including convenience for your users, from easier maintenance to network administration. Automatic updates require attention to factors such as discovery, security, and file replacement. In this article, the author covers the BITS API as well as a number of features of the .NET Framework that take care of these facets of auto-updating using the same facilities that the Windows Update uses.

Jason Clark

MSDN Magazine February 2003

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];

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