In my site, when a user registers, I need to create rows in additional tables besides aspnet_Users. So, I need to be able to pass the generated userId guid to subsequent SqlCommands. I'm having a terrible time with this. What's the correct way to set up a SqlParameter so that it will accept a guid? I keep getting this error: "Conversion failed when converting from a character string to uniqueidentifier." I've tried creating the parameter both with and without a SqlDbType. cmd.Parameters.AddWithValue(paramName, guid); and SqlParameter p = new SqlParameter(paramName);p.SqlDbType = SqlDbType.Guid;cmd.Parameters.Add(p); and I get the same error either way. Driving me nuts! Any help appreciated.
What different are there between connectionString (Part 1) and connectionString (Part 2) in web.config The CCWW is my PC's name, normally I can connect to the database ASPNETDB.MDF correctly either Part 1 or Part 2 in a web page,After I open Database Explorer panel and browse ASPNETDB.MDF, I can't connect to database using Part 2 when I open a webpage in Microsoft Visual Web Developer 2005 Express Edition,but I can correctly open a webpage using Part 1 after I open Database Explorer panel. What different are there between connectionString (Part 1) and connectionString (Part 2) in web.config? I guess while I use Part 1 to connect, maybe it will be cancel exclusive method of the database ASPNETDB.MDF first, but when I connect to database using Part 2, maybe two programms both Part 2 and Database Explorer visit ASPNETDB.MDF at the same time!
Hi there everyone, this is my first post so go easy on me :) Basically I am trying to get my database to copy the value in the UserId (unique identifier field) from the aspnet_Users table to a foreign key UserId in a table called userclassset. I have made this field the same datatype and created a relationship between the two. Unfortunately, when I add a user using the ASP.Net configuration tool it does not automatically copy this value into my own custom table. I have noticed it is however automatically copied into the aspnet_Membership table. Any pointers on how to solve this would be great! Thanks :)
i need to auto generate the user id in id colunm in my sqldatabase table.i want it to generate in this fashion.(mycompanyname-todaydate-number.)eg (ibm-15thfeb-1) (ibm-15thfeb-2) (ibm-16thfeb-1)here i need this user id to be automatically displayed in my web form when doing registration of new user,then only after clicking the savebutton i want all the data along with user id to be inserted into the table in sqldatabase.thanksjack.
I am trying to configure a sqldatasource control using the where clause to grab a single record with a certain UserId. Teh UserId is stored in a variable of type System.Gui and I cant seem to figure out how to do this. Can someone give me a hand please?
I'm trying to sort by domain user id, I can pull the user id fine but now I want to sort my SELECT by that name. How do I put the value of getUserIdentity into my SELECT statment. Thanks <script language="C#" runat="server"> protected string getUserIdentity() { return HttpContext.Current.User.Identity.Name.ToString().Replace("DOMAIN\", ""); } protected void Page_Load(Object sender, EventArgs e) { username = getUserIdentity(); SqlConnection myConnection = new SqlConnection("Data Source=CLIENTELE;Initial Catalog=forms;Integrated Security=True"); SqlDataAdapter myCommand = new SqlDataAdapter("SELECT * FROM formTable WHERE userID = @username ORDER BY status DESC", myConnection); DataSet ds = new DataSet(); myCommand.Fill(ds, "names"); MyDataGrid.DataSource=ds.Tables["names"].DefaultView; MyDataGrid.DataBind(); } </script>
Currently, I am using a varchar "UserName" as a primary key instead of an Identity or GUID.
System Info: When user's sign up they provide the "UserName" that is used as a PK. Creating a message board type web application. UserNames will never change. UserNames are used extensively as FK's in other Tables. We want to scale well.
Does anyone know the implications? I understand Joins are faster on numerical values than strings but we will not be performing many joins.
In my case is it better to use Identity as a PK or is it better to use a varchar for a "Users" table?
I wrote trigger to insert old data before update or delete . Now while inserting i want to insert userid and machine id for user id ia tried the following query as
SELECT CURRENT_USER; it retuns o/p as dbo Please give me solution
I have installed Sql Server 2000 Reporting Services. I desinged report in VS 2003.When press F5 key.Every time it is asking for user id password then only it is giving List of Report Names.
Is there any way to avoid giving user id and pwd every time. Regards.
I am creating a new application and just created a new database Application: VB.net 2005/ ASP.net Database: Sql Server 2005 with four tables I need to set the userid and password on the database. How do I do that? I want to be able to create a SQL connection object in my code and I have something like the following: <CODE> Dim objcon As New SqlConnection("server=serverName;uid=;pwd=;database=SomeDatabase") </CODE> but the "uid" and the "pwd" are not set on my database. what is an easy way to do this? thanks
Well, I want to store my customer records in two tables in an SQL Server 2005 Database. (Visual Studio 2005 with ASP.Net and C#). I want to create a unique ID for each user which starts with either an IN or a CO (indivudual or Company). This information is stored in two seperate tables, one table called individual and one table called company. I want my individual table to store a unique ID with IN************, so it should have IN followed by a 12 digit unique ID. I want my company table to store a unique ID with CO************, so it should have CO followed by a 12 digit unique ID. I'm afraid Unique IDs are something im not very familiar with, so any help would be greatfully appreciated, but please be clear as I have a bit of trouble understanding. I wouldn't know how to even begin this, as I have trouble using simply the UniqueIdentifier attribute. Thank you in advance for any help!
Hello!I work with oracle, mySQL but im completely new to SQLserver.How can i set a auto-increment unique variable for userID ?After deleted user, the userID should be never used again on a new user.Thank you,
I have a user which has the currect rights to do what he needs but others with the same permissions (from what I can tell) can not do somethings. It looks like I have 2 options
a.) find a way to mirror the working one to 30 others ids or b.) find some tool that will do a detailed comparision of the two ids
Any suggestions/tools(free)/scripts that would work?
I have the following situation: I have a table that is log of transactions of useractions. Each time a userstatus changes, a new entry is made into the table.
The table has (currently) about 4 million records, and keeps growing each day with thousands of records. It logs the status of about 150 users (currently active).
What I now want is to get the log-entry from all the distinct users that have a log-entry on the latest day (so current day, 'where TimeStamp > 2008-04-08').
(extremely simplified) Example: (date is y/m/d)
USERID TIMESTAMP STATUS ---------------------------------------------------- ... (thousands and millions of records above) Ed 2008-04-07 18:00:00 Logged_Out Jim 2008-04-07 18:30:00 Blabla_Status_5 Jack 2008-04-07 19:00:00 Logged_Out Jim 2008-04-07 19:30:00 Logged_Out Jim 2008-04-08 06:00:00 Logged_In (<< notice new day) Jim 2008-04-08 06:01:00 Blabla-Status_1 Bob 2008-04-08 06:03:00 Logged_In Fred 2008-04-08 06:05:00 Logged_In Jim 2008-04-08 06:08:00 Blabla-Status_2 Jack 2008-04-08 06:12:00 Logged_In Fred 2008-04-08 06:20:00 Blabla_Status_5 Jack 2008-04-08 06:12:00 Logged_Out Fred 2008-04-08 06:12:00 Blabla_Status_4 Jack 2008-04-08 06:12:00 Logged_In Jack 2008-04-08 06:12:00 Blabla_Status_7 ----------------------------------------------------
The result should be:
USERID TIMESTAMP STATUS ---------------------------------------------------- Jack 2008-04-08 06:12:00 Blabla_Status_7 Fred 2008-04-08 06:12:00 Blabla_Status_4 Jim 2008-04-08 06:08:00 Blabla-Status_2 Bob 2008-04-08 06:03:00 Logged_In ----------------------------------------------------
I am writing a VBscript which takes my machine details and put in the SQL database.
But after executing the script , i got the following error: Microsoft OLE DB Provider for SQL Server: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
I dont remember the password I have given during installation. Please tell me how to get the password of sql server.
I use DTSRun /Uuserid /Ppassword /Sservername .... in a batch process. I always get the error message to run with a trusted connection. I can run the same batch process from a command line under my own domain id and it runs as if it had a trusted connection. Will DTSRun run only with a trusted connection? Do I need to set something in the package to get SQL Server to run with a userid and password? Why does it always default to using a trusted connection. I need to know what I have to set to tell it that I am using a userid and password. I have included an example of how it's coded in the BAT file.
When I tried to browse the reportserver url. The IE 7.0 asks me for Username and password. I feel, its some settings related to security. But other sites created are working fine. The virtual directories created using Repoting services configuration manager only ask me username and password.
I have recently had a few reports that are built around the userid parameter start failing to pass the userid parameter. If I run the report and hard code the userid everything runs just fine, but I am not able to collect the userid when the user is logging into the report server. Any thoughts or suggestions?
I want to join my existing tables such as ORDERS with aspnet_Users.UserId on ORDERS.CustomerId.But I am confused which data type should I choose for customerId field.The datatype of the of aspnet_Users.UserId is uniqueidentifier, but obviously I cannot assign my customerId field to uniqueidentifier data type. I found that "The uniqueidentifier data type in SQL Server is stored natively as a 16-byte binary value." I wish aspnet_Users.UserId would be an integer IDENTITY field. I also want to ask if I can change UserId field's datatype to integer?There are also some other tables that I want to join with aspnet_Users table on its UserId field. Can you suggest any solutions?
Hello everyone,i have a web form to take user details.as soon as the submit button is clicked the form is submitting and the new row is being added into the sqldatabase.its fine ..but in the newly added row, i want the user id(primary key and auto generating) to display in different manner.in mytable column(userid),instead of userid auto displaying 1,2,3,4 ...i want it to display in this way.these are all primary keys of rows added.todaydate-username-1 eg(2.2.2008-jack-1)todaydate-usernaem-2 eg(2.2.2008-zak-2)todaydate-usernaem-3 eg(2.3.2008-leme-2)any idea how to achieve this.?thanks.jack.
While deploying reports on the reports server, it is asking to supply user name and password. When I entered the same, it didn't accept them. What do I need to do? Is there any specific setting which I need to configure?
Hi, I am using the sql server for creating the database. I want to create the database which is having userid and password. This I require since I wanted to restrict acces to database and also only authorise user to database can use the userid and password created at time of creation of database. So how can I create the database which is having userid and password?
I have to implement table level loggin on a bunch of tables. The problem is that I also have to log the user that made the changes
Obviously the right way would be to run everything tru stored procs - but that is not possible for me because there is a lot of existing functionality built already - some direct sql and a super large number of sprocs.
So I wanted to go with a trigger based approach .However since the changes are being made by a web app SQL has no idea who the actual web application based user is.
I originally tried to solve the problem by adding a LastUpdatedBy column to some of the tables and forcing the functions to update that too - so that the trigger can read that column but that has turned out to be very tedius and buggy.
So I want to try something else - so far it seems to be working but I just want to make sure I am not messing up anything along the way.
There is a function is TSQL called APP_NAME() , this return the name of the application that started the connection that the TSQL is running in. This made scense during the desktop days when it would return the actual .EXE name of the file that executed the changes.
Nowadys it's not so usefull any more becuase in a web based app all changes are being done by aspnet_wp.exe so i don't know if that info is usefull - as a matter of fact all access thru ado.net default to ".Net SqlClient Data Provider" .
So my thinking is like this - if I add 'Application Name= userid" to the connection string before I open it - then I will have access to that userid thruout any changes that usermakes via APP_NAME()
I realize that I may be messing up the connection pool a bit - but I have relativley few (60) users who are on the system for long spans - so each one will be able to reuse their own connectiions.
I just want to make sure before I go off on this that i am not messing things up badly
Just installed Express edition on my laptop and don't know how to set up the connection string in my aspx.vb page. I've added my connection in the webconfig page and want to set up the vb page. This is not working please tell me what's missing in the Dim conn section.Protected Sub SubmitInfo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitInfo.Click Dim conn As ConnectionStringsSection = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|BEEN.mdf;Integrated Security=True;User Instance=True"Dim cmd As New Data.SqlClient.SqlCommandWith cmd .Connection = conn .CommandType = "AddUserInfo".Parameters.AddWithValue("@FName", Fname.Text) .Parameters.AddWithValue("@LName", LName.Text).Parameters.AddWithValue("@Email", Email.Text) .Parameters.AddWithValue("@Comments", Comments.Text) End With conn.Open() cmd.ExecuteNonQuery() conn.Dispose() End Sub
Hi I'm using Sql Server (SQLOLEDB.1) and I want to connect it by Sqlconnection.those are the details:user Id: saPassword: *****database: ServiceManagementserver name: KLXPE002KULMOSWhat should be the Connection String? Thats what i did: "Persist Security Info=True;Integrated Security=SSPI;server=SQLOLEDB.1;database=ServiceManagement;Data Source=KLXPE002KULMOS;User ID=sa;password=****"It doesn't work.thnxItai
Hello, I have just tried to deploy my app from my local pc to our server and I have been getting this error. Server Error in '/' Application.
Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.Source Error:
Line 164: <providers> Line 165: <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" Line 166: type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> Line 167: <add name="AspNetWindowsTokenRoleProvider" applicationName="/" Line 168: type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />Source File: C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Configmachine.config Line: 166
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42 I am new to SQLExpress 2005 and asp.net 2.0. I created some database files on my local pc then copied the whole app to the server. Not sure what to do. Any help would be greatly appreciated or direction to info. Thanks Matt
The server is on the localhost, the database name is ok, but what do I put in for the username and password?, At the moment because it is hosted locally I am not using any logins.
Im a bit confused on my programming skills. I know how to add a user and password using the Membership.CreateUser class. ' Define database connection Dim conn As New SqlConnection("Server=localhostSqlExpress;" & _ "Database=lnp;Integrated Security=True") ' Create command Dim comm As New SqlCommand( _ "SELECT oldLogId, oldPassword FROM userDetails WHERE (oldLogId = N'chuck') OR (oldLogId = N'top_dawg')", conn) ' Open connection conn.Open() ' Execute the command Dim reader As SqlDataReader = comm.ExecuteReader() ' Do something with the data While reader.Read() Dim partPassword = reader.Item("oldPassword") ' Adds underscore character and first 3 letters of password for distinct USER ID Dim newUserID = reader.Item("oldLogId") & "_" & partPassword.SubString(0, 3) ' Create User if Valid Try Membership.CreateUser(newUserID, partPassword) Catch ex As MembershipCreateUserException ' Code that is executed when an exception is generated ' The exception's details are accessible through the ex object usersLabel.Text &= "<p><strong>Exception: " & newUserID & "</strong><br />" & ex.ToString() & "<br /><strong>Message: </strong><br />" & ex.Message & "</p>" End Try End While usersLabel.Text &= "<p><strong>END OF RECORDS</strong></p>" ' Close the reader and the connection reader.Close() conn.Close() But now I want to do something in a Stored Procedure USE [lnp]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROCEDURE [dbo].[sp_createPortingDetailsWithUsers]-- Add the parameters for the stored procedure here @passUserId NVarChar(50), @passPassword NVarChar(50)ASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;Membership.CreateUser(@passUserId, @passPassword)Select SCOPE_IDENTITY()ENDBut when I try to execute this in SQL SERVER MANAGEMENT STUDIO EXPRESS, I get an error near the line MEMBERSHIP.CREATEUSER(@passUserId,@passPassword)Msg 102, Level 15, State 1, Procedure sp_createPortingDetailsWithUsers, Line 11Incorrect syntax near 'Membership'. What I want to do is create a user with a UserID and Password that I am passing from a table and then retrieve the USERID (unique identifier) when I create the new user. Can anyone suggest or show a tutorial on what I am doing wrong? I appreciate any assistance in advance,Chuck
I am making a web site in which i need to update a database with certain values which include the current user who invoked the insert command so how to retrieve the current userID
Hi I am using ASP.Net user management tool. How can I get the user name of the current user who does some activity to log those details using triggers.Any web link/tool/suggestion is welcomed.