Web Forms :: Matching Logged In Userid To ID In Another Table?
Feb 2, 2011
So I have been trying to pull the userid of whoever is currently logged in and match it to another table that it is a fk in. I have some code that should work but I get an error that says specified cast is not valid in line 10.
here is the code I have behind file:
[Code]....
View 4 Replies
Similar Messages:
Dec 4, 2010
How can I get the exact ID of a user that is logged into a site?
I'm using the login and registration controls created by Visual Studio 2010, in the database the unique identifier is in this 28e8957e-00b8-4e75-bec9-2b90e640962d for example how can I return the exact one to be used in an SQL command for example?
View 1 Replies
Mar 31, 2011
I have a confusing question, I have a user table and it stores all the usual data for a user that you would expect but im trying to figure out how a user could add another user?
Sounds strange but each user in the User table has his own UI which is UserID how could I add another table where UserID can have a relationship with another UserID?
i.e how would I right the syntax for the above question if I wanted to display all the UserIDs friends on a page. How would I add a friend.
View 4 Replies
Aug 20, 2010
I'm trying to get the current logged in UserId Value, using this code
[code]...
But, I getting an error (NullReferenceException), I did set a url authorization on the page that i try to get the logged in user information, witch is info.aspx, and I made the login.aspx control to be redirected to the info.aspx after the login process, But the info.aspx only shows me (access in denied), how can i make this page knows that i am already logged in?
View 3 Replies
May 7, 2010
i am trying to show a list of users of my application "school", when admin logs in then he can view all the users in list but when school principals logins, he should get only users of his school, So i thought to get the current loggedIn userId first and then by that userId i'll get schoolId since userId is foreign key in school table...once i'll get the schoolId i can show the members of that school.
But my problem is how to get the UserID of currently loggedIn. I'm using MVC 1.0 Asp.Net -- "Membership" if my logic above is wrong then tell me the alternate good idea, so that principal can see only his users list.
View 3 Replies
Jul 21, 2011
I am creating a few web services for use with a mobile application. My current site uses asp .net membership and one of the web services will validate username and password.
In the web service I get passed uname and pword and just use
Code:
If Membership.ValidateUser(username, password) = True Then
Return "True"
Else
Return "false"
End If
Is there a similar way to get the userid without logging the user on or do I need to create a Stored procedure?
View 2 Replies
Jan 14, 2010
I have a gridview nested inside a Loggedin Template so when a user logins it will display their own details (name, address etc) When i attempt to run this i get this error message:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
[Code]....
View 21 Replies
May 17, 2010
I have a web application which uses a session variable to store the logged in userid. If no user is logged in, of course this variable will be empty and the contents displayed on my website are meant for guests. If there is a user logged in, the user specific controls/access/links will then be a displayed.
I am now having issues with my hosting where on shared application pool, the worker recycle is triggered every 90 minutes, this will clear sessions causing all my users to be logged out. I opted for a dedicated application pool, which got worse because I am only allocated 50MB memory limit and if this is reached, the worker recycle is triggered and I lose my sessions again. I have tried as much as possible optimization techniques, e.g. dispose where possible, close connections, disable viewstate for static controls etc but my memory per instance keeps building up from page to page without any signs of improvement. I don't use loops nor store huge objects like bitmaps etc but my sessions are now gone even faster than 90 minutes in shared application pool before.
I have considered using SQL Session State but there isn't a simple guide on using this with MySQL. I am getting desperate and considering using a public variable, a string as a replacement to store logged in user id instead of in a session variable. I am pretty sure this will solve my issue with sessions being recycled but are there any negative consequences of doing this? One problem I can think of is if the user closes the browser, the system will never know that the user is now logged out and this public variable should be nothing. In this scenario, will the GC eventually clear this abandoned public variable.
View 10 Replies
Jan 29, 2011
Inner Join:- Returns a row when there is matching table in both tables. we can use comparison operator like =,<,>,<>
I created two tables
TableA
ID OID Type
1 1 A
2 6 B
3 7 C
4 10 D
TableB
ID Value
1 10
2 30
3 40
5 60
6 70
Basic Inner Join select Type From TableB as a inner join TableA as b on a.ID=b.OID Result Type
A
B
If i want only the type which has not match in tableB then i can use not in subquery i get the result if i m using select Type From TableB as a inner join TableA as b on a.ID<>b.OID then i get
Type
A
A
A
A
B
B
B
B
C
C
C
C
C
D
D
D
D
D
18 rows affetected i m suprise
View 3 Replies
Oct 21, 2015
Default.aspx**
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="admno"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="admno" HeaderText="admno" ReadOnly="True" SortExpression="admno" />
<asp:BoundField DataField="bcode" HeaderText="bcode" SortExpression="bcode" />
[Code] ......
View 1 Replies
Aug 25, 2010
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).
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.
Dim cmd As New SqlCommand()
' Assign the connection to the command.
cmd.Connection = conn
' Appendy the parameter to the SqlCommand and set value.
cmd.Parameters.Add("@UserId", SqlDbType.UniqueIdentifier).Value = Guid.Parse(Request.QueryString("UserId"))
' Set the command text
' SQL statement or the name of the stored procedure.
cmd.CommandText = "SELECT Avatar FROM aspnet_Membership WHERE UserId = @UserId AND Avatar IS NOT NULL"
' Set the command type
' CommandType.Text for ordinary SQL statements;
' CommandType.StoredProcedure for stored procedures.
cmd.CommandType = CommandType.Text
' Open the connection.
conn.Open()
' Convert the returned result to a bytes array.
Dim bytes As Byte() = DirectCast(cmd.ExecuteScalar(), Byte())
If bytes IsNot Nothing Then
' Set the HTTP MIME type of the output stream.
Response.ContentType = "image/jpeg"
' Write a string of Binary characters to the HTTP
' output stream.
Response.BinaryWrite(bytes)
' Send all currently buffered output to the client.
Response.End()
Else
args.IsValid = False
End If
End Using
End If
End Sub
View 9 Replies
Feb 11, 2010
I created the Table Profile Provider with the VB.NET and it works perfectly but I have one issue with it.. My Table (UserProfile) can't be linked with any other tables because the UserID on userprofile is different than any other table yet when I do profile.firstname on the vb code it works perfectly. Say for example I have a username called john If I do select * from aspnet_users where username = 'john' The results would come to 2 rows, 1 which has a userid and applicationid that is used on ALL the tables in my database EXCEPT for userprofile The second one would have a applicationid and userid that is only use on my userprofile table.
View 1 Replies
Apr 15, 2010
I have a table for which I'd like to filter rows based on whether or not they contain a hidden field matching a value.
I understand that the technique tends to be "show all rows", "filter the set", "show/hide that filtered set"
I have the following jquery but I'm aweful with filter and my filtered set seems to always contain no elements.
my table is the usual
<table>
<tr><td>header></td><td> </tr>
<tr>
<td>a visible cell</td><td><input type='hidden' id='big-asp.net-id' value='what-im-filtering-on' />
</td>
</tr>
</table>
My goal is to be able to match on tr who's descendent contains a hidden input containing either true or false.
this is how I've tried the selector (variations of this) and I'm not even testing for the value yet.
function OnFilterChanged(e){
//debugger;
var checkedVal = $("#filters input[type='radio']:checked").val();
var allRows = $("#match-grid-container .tabular-data tr");
if(checkedVal=="all"){......
View 3 Replies
May 21, 2010
I get this error while trying to run my project: "Column name 'UserID' appears more than once in the result column list." Indeed, the query generated in my SqlTableProfileProvider.vb is the following (text in brackets [] has been changed):
"IF EXISTS (SELECT 1 FROM [table] WHERE UserId = @UserId) BEGIN UPDATE [table] SET UserID=@Value0, LastUpdatedDate=@LastUpdatedDate WHERE UserId = '[Guid]'END ELSE BEGIN INSERT [table] (UserId, UserID, LastUpdatedDate ) VALUES ('[Guid]', @Value0,
@LastUpdatedDate) END"
I'll emphasize that the above statement is generated in SqlTableProfileProvider.vb, which was written by .Net people. While I have little control over its source, I've apparently given the fodder whereby the mistake can be generated. Any clues as to why UserID is being written twice in the statement?
View 2 Replies
Feb 6, 2011
It sounds pretty simple, but I can't find a way to make it work. I have a FormView with a InsertTemplate where it inserts the current logged in user's UserId and content from a HTMLeditor, and a EditTemplate where it retreives the current logged in UserId and shows content from database in the HTMLeditor.
How can I get it to show EditTemplate if the userId exist in the table, and InsertTemplate if the UserId does not exist in the table?
View 4 Replies
Feb 18, 2010
implementing an file upload control that uploads the binary data to the database table and associates it with the correct user/the current user who uploaded the data.
View 8 Replies
Feb 10, 2011
I'm creating a web project for one of my uni modules using Visual studio 2010. I'm using asp.net membership and have all of my sql-server tables set up correctly (I'm pretty sure).
I have a form that I have created myself that inserts into the database using sqlDataSource.insert(). I had some problems initially with not being able to insert any data into the table at all, but I have cleared that up.
My problem now is that I need to insert the currently logged in user's userID into one of the columns of the table. But every time I hit the submit button, I am told I cannot insert null values in the userID column.
I can retrieve the userID using this snippet:
[Code]....
This is the code behind for the page:
[Code]....
As you can see it is a bit of a mess, I've been frantically trying different variations, as I need to catch up a little with other uni modules.
Here is my SQLDataSource from the .aspx page, The controlparameters work fine for the other data I am inserting. maybe the <asp:parameter name="userID" /> is wrong?
[Code]....
I'm relatively new to vb, and I come from a html & css background.
View 1 Replies
Jun 6, 2010
i'm new to membership. i have a table named contact, with a field, userId that must get its data from the membership users table. so when a user is created i have to get the userId from membership users table. how can i do that?
View 1 Replies
Oct 1, 2010
i'm using asp.net membership for logins/registeration. i have a bookings table with few fields, lets say first_name, last_name, product_name and userID.when the user submits 'buy' i want to get the userID from the membership user tablem that way i know whose made the booking. i'll have these two tables (bookings & user tables) linkedbut how do i get userID from the user table to pass to bookings table? i checked the membership class and it gives options like-Membership.GetUser(), Membership.GetUserNameByEmail(), Membership.GetAllUsers() etcothing for getting user id. user id is stored like this: c1c91682-449f-45dd-b20e-3dac5315bba4
View 2 Replies
Sep 25, 2010
[Code]....
View 9 Replies
Jun 27, 2010
I recently read Scott Mitchell's article series "Examining ASP.NET's Membership, Roles, and Profile". In Part 6 [URL] It says "to store additional, user-specific fields...If you are using the SqlMembershipProvider, this would mean creating an additional database table that had as a primary key the UserId value from the aspnet_Users table and columns for each of the additional user properties."
I created a table named Thread to store some specific users information and comments they make. I set the ThreadId as the primary key and the UserId as the foreign key to the UserId in aspnet_Users table. But when I run the application and use a user's account to submit a comment, there is an error in my Comments.aspx.vb page "Cannot insert the value NULL into column 'UserId', table 'ASPNETDB.dbo.Thread'; column does not allow nulls. INSERT fails.The statement has been terminated."
How can I make the logged-on user's UserId inserted into the Thread table when storing the user's other data information?
View 6 Replies
Nov 18, 2010
There are lots of posts about this issue but I can't work out the answers as most of them are for C# or similar. I'm trying to automatically insert the UserId generated by Membership into a custom table. I have membership working correctly, as well as the custom table (I'm able to insert other things from the registration form). But I can't get it to extract the generated UserId and insert it into the custom table. Here's my code:
[Code]....
As you can see I've experimented with the parameters for inserting the record, but that doesn't work (I get an error about ProviderKey not being a part of system.web.security.membershipuser).
View 3 Replies
Aug 10, 2010
Perhaps this is a simpler VS9 question, but I want to link a SQLServer table with additional user data to the standard SQLServer membership table using the GUID userID as a foreign key. I go into design mode of my table, right-click on relationships, and click add in the dialog. but the left hand column shows me only the tables in my database. How do I get it to show the tables in the ASPNETDB.MDF database? I went through the tutorial (http://www.asp.net/learn/security/tutorial-08-cs.aspx), but it seems to magically appear in there without explanation.
View 3 Replies
Apr 2, 2011
I'm trying to select UserID, FirstName, SecondName, PicturePath(from Pictures table) LIKE FirstName (string search = textbox.text)
OdbcCommand("SELECT UserID, FirstName, SecondName, p.PicturePath FROM User LEFT JOIN Pictures p ON p.UserID = u.UserID WHERE FirstName LIKE '%" + search + "%' ORDER BY UserID DESC", cn))
My syntax is way messed up. My table structure:
View 4 Replies
Mar 24, 2010
I have set up security on my ASP.NET site and currently have 1 user (soon to be more!). I would like to send the logged-on user's username to a variable, to input this value to a custom-designed stored procedure on my SQL database (for recording search statistics).Does anyone know how I can harness the current logged-on users username? I am using VB. Will the following achieve the result?session(username)If so, how do I implement this? I tried using "Current_User" in the SQL stored procedure, but obviously this did not record the ASP.NET user. Also, if the current user has not logged onto the site, I would like the "username" value to be "annonymous".
View 10 Replies