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

Top 5 Contributors of the Month
Post New Web Links

ASPNETDB UserId as UniqueIdentifier, why ?

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
I'm just curious, why its not bigint or int ? is that because GUID is easy to generate ?

View Complete Post

More Related Resource Links

selecting with SqlDataSource by UserId (uniqueIdentifier)



i'm trying to select records by userId (which is a uniqueIdentifier) but it doesn't work:

i tried writing:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" OnSelecting="select2"
          SelectCommand="SELECT * FROM [delta] WHERE [userId]='Membership.GetUser().ProviderUserKey.ToString()" ConnectionString="<%$ ConnectionStrings:MyDB %>" />

 but it didnt work and gave me an exception saying: Conversion failed when converting from a character string to uniqueidentifier

what's wrong?

WebMatrix conversion failed when converting from a character string to uniqueidentifier?


I am trying to retrieve xml from a small function in my .cshtml page. Its throwing me an error. This however, runs fine in a console/form environment.

It takes 3 parameters and 1 exception.

myDll.GetXML(year, username, uniqueidentifier, out ex);

When I run this page I get the error, "Conversion failed when converting from a character string to uniqueidentifier."

Or a stack of.

System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting from a character string to uniqueidentifier.

   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()

   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()

   at System.Data.SqlClient.SqlDataReader.get_MetaData()

   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBeha

insufficient result space to convert uniqueidentifier value to char


Hi guys,

       Look, I've been trying to insert new values while I create a new user with a createuserwizard, but I've been getting this error over and over again:

"insufficient result space to convert uniqueidentifier value to char"

       The code that does it is the following:

  protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
TextBox UserNameTextBox = (TextBox)CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName");

SqlDataSource DataSource = (SqlDataSource)CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo");

MembershipUser User = Membership.GetUser(UserNameTextBox.Text);

object UserGUID = User.ProviderUserKey;

DataSource.InsertParameters.Add("UserId", UserGUID.ToString());


      But when I debug, the error is thrown before reaching the previous code, so I suppose the error is in the SqlDataSource, look:

      <asp:SqlDataSource ID="InsertExtraInfo" runat="server" Co

=User!UserID from windows authentication using table from another database



i'm using sql server 2005, sql server business intelligence development studio for my reports and deploy them in my wss3.0 site.

what i'm trying to do is i'm trying to restrict wich users can see specific data within a report.

now, the thing is. the report gets the data out of my DB1 database and my windows authenticated user are in the WSS_content database.

when i deploy my report in my wss3 site. it gets the user that is loged in. but of course it does not display any data because the tables are not in the same database.

does someone knows how to do this?

How to make "UserId" equal to the "logged-in user" in vb code behind


I need to insert a declaration in the codebehind function below that will make the variable "UserId" equal to the "logged-in user". In what way do I need to change the code below (elsewhere in the project, I successfully make reference to basically the same code and make the UserId equal to logged-in user by using this handler expression inside an image control: ImageUrl ='<%# Eval("UserId","Image.aspx?UserId={0}")%>'...But in the case below, the function is not fired by this expression, but rather by CustomValidator). Thanks very much.


Sub ValidateImage(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)

        If Request.QueryString("UserId") IsNot Nothing Then
            ' Get the connection string from Web.config.

            Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("MyDatabaseConnectionString").ToString())
                ' Create a command object.

Run report without be prompted for UserID and Password

I have not had any luck creating a simple report that doesn't prompt the user for a ID and password when they execute the report URL. Our goal is include the URL link to a specific report in our web-based application. The webserver, (sitting on the DMZ) will direct the HTTP traffic to our application server (Tomcat inside our firewall). The finished report URL resides in a web based application in Tomcat which will direct the HTTP traffic to SSRS. The user will not be prompted to run the report in SSRS when they click on the URL link in their application. I have tried to update the data source properties by adding a service ID and checking both boxes (1) Use as Windows credentials, and(2) Impersonate the authenticated user after connecting. Nothing I have tried works. I copy the URL of the finished report, and past the contents in Firefox (where my AD credentials are not cached.) I still get prompted for a User ID. Any help will be highly appreciated. Is anybody out there trying to run reports using a URL residing on their external application? Thanks again for your help!

ASP.NET MVC2 Empty Web Application creates ASPNETDB database when I try to add user to my own databa

I created ASP.NET MVC2 Empty Web Application, I added my own database called 'Database1' and I added to this database Microsoft users, permissions etc. tables but when I create user in ASP.NET Configuration - it creates in catalog /App_Data database called 'ASPNETDB' and adds users to this database - I don't want that - I have my own database for that - what is going on ??In Web.config my ASP.NET MVC application I have only one connectionString - my own:<add name="Database1Entities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" /> so what is going on ? How can I add users to my database 'Database1' ?

ASPNETDB.mdf & SQL Server 2008 R2 Express

Please help!! I am using Visual Web Developer 2010 Express to develop web site.  It generates a ASPNETDB.mdf when using login, etc.  How can I access this database.  Have SQL Server 2008 R2 Express on my PC.  I want to link existing SQL Server 2008 R2 Express db to this one, ie to display listings for user logged into web site.  How do I do this? Thanks!!

Need help configuring access to the ASPNETDB

I am very new to ASP.NET (and html and all that goes with it), as well as SQL. I would like to be able to use the currently logged in user as key for multiple tables, but in order to do that I need to access the ASPNETDB. (It is quite handy to use the logged in user as key for various purposes, right? I mean, it is a good way of handling things?) I have trouble figuring out how to set it all up correctly thought. I have been searching the web, and lately these forums, for answers, but so far, no luck. I am using Visual Studio 2010 Professional and Microsoft SQL Server 2008. No IIS installed (as far as I know); the ASP.NET Development Server seems to be used. I have an ASPNETDB.MDF in both "Data Connections" in the Server Explorer, as well as in the "App_Data" folder in the Solution Explorer. I have attached this database in SQL Server Management Studio. In Visual Studio, when I click Tools->Connect to database and enter the server name, I get a list of the databases I have attached in Server Management Studio. If I select ASPNETDB there and press "Test Connection" I get a "Test connection succeeded.". I guess that means I can access it. Now, how do I go about configuring all this in the web.config? Should I use the full path (I:\Programming\Projects\ASP.NET\Website6\App_Data\ASPNETDB"), or s

Casting issues when using WHERE and uniqueidentifier

Hello all, I am getting the same error when trying to build the queries below by using 2 diffferent methods: DECLARE @stepIds varchar(8000), @instance uniqueidentifier, @instance_binary binary(16) SET @stepIds = '' SET @instance = '28B2D4FB-67F6-40CA-84A2-839BF3CC4B91' SET @instance_binary = CAST(@instance AS binary(16)) SELECT @stepIds = @stepIds + ',''' + stepID + '''' from Uds.RealtimeLogging WHERE instanceID = @instance_binary --Conversion failed when converting the varchar value ''' to data type int. --OR DECLARE @stepIds varchar(8000), @instance uniqueidentifier SET @stepIds = '' SET @instance = '28B2D4FB-67F6-40CA-84A2-839BF3CC4B91' SELECT @stepIds = @stepIds + ',''' + stepID + '''' from Uds.RealtimeLogging WHERE instanceID = convert(uniqueidentifier, @instance) --Conversion failed when converting the varchar value ''' to data type int. Thank you  JCD

An attempt to attach an auto-named database ....\aspnetdb.mdf failed

I've installed VWD 2005(Beta 2) and MS SQL Express and also followed the aspnet tour at http://beta.asp.net/guidedtour2. After trying new webcontrol (login control) and trying to execute the page, I've got an error such as below: An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Demo\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Demo\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace: [SqlException (0x80131904): An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Demo\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.] Syste

ASPNETDB.mdb and SQL Server 2008 R2 Express link

Hello I am new to ASP.NET - still learning! I have SQL Server 2008 R2 Express and Visual Web Developer 2010 Express installed on my PC.   I want users to login to my site and add listings that must be linked to their username.  ASP.NET generates the ASPNETDB.mdb file when using login / membership function. How do I access this database from SQL server 2008 R2 Express ? How do I link this database to my own SQL express database? Please help!!!

1 aspnetdb for multiple domains

Background: My GoDaddy Hoste account currently hostes the website for the entire league, and multiple team websites (with hundreds more to come with growth).  Each team website is built from a template, has a unique URL and is hosted in a directory dedicated to that domain. aspnetdb: Each team's administrator logs into the team website to make changes.  I learned to make use of the Login controls and Microsoft's aspnetdb and was inspired to have one, single aspnetdb database to serve all team websites.  It works just fine, or so I thought.  The problem is that the administrator credentials work for all websites - so the adminstrator for team A can have lots of fun with team B's website. The Question: How do I reconfigure the aspnetdb database to allow for the following: Master Adminstrator (me) that can log into all websites Team Adminstrator that can only log into his/her own team website - not the others. Please help!  Thanks.

automatically aspnetdb is created in app_data folder

 i have used membersip, roles, profile in my website. i have moved all the tables and sps to the new database i am using. to avoid creating aspnetdb. i use sqlexpress and visual web express. My problem is aspnetdb is automatically created event though i have not used 'localsqlserver' specified anywhere in the web.config file.  I not able to understand why aspnetdb is automatically created in the app_data folder. Any ideas..

user!userID limits data by supervisor but want director to see everything

Ive used user!userID  to limit the information by who is logging in and it works fine, but I have a few directors that I want to see everything- how would I accomplish this ?? Let me know if anyone needs additional information thansk kam

Can't add ASPNETDB.MDF to ASP.NET 4 Web Site project [SQL Server 2008 R2 Express]

I'm using SQL Server 2008 R2 Express and try to add ASPNETDB.mdf database to my web site project. However, the following message appears: "Connections to SQL Server database files (.mdf) require SQL Server 2005 Express or SQL Server 2008 Express to be installed and running on the local computer. The current version of SQL Server Express can be downloaded at the following URL: http://go.microsoft.com/fwlink/?LinkId=125883". In spite of this message, however, database appears in App_Data folder. What is wrong?

Use of aspnetdb configuration for user login,roles and all



I created a web application and i created the users,roles and all using the asp.net configuration,

the aspnetdb is created and i include that in my project adn run it it works fine.

then i copy the whole folder in my root folder of my IIS and it works perfectly fine

Now if i want to create the whole project into an exe such that  if i run the exe on a system that has iis on it,it should automatically create the virtual directory and i shud be able to run it from the new server.

i tried it but the login is not working,

Can you help me finding out the exact way in which i can create the login features using the asp.net configuration.

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