Showing posts with label authentication. Show all posts
Showing posts with label authentication. Show all posts

Friday, March 16, 2012

"Remember Password" feature behaves like child with Attention Deficit Disorder

In Sql Server Management Studio, when you connect to a server using SQL Server authentication, there is a checkbox "Remember Password". This is really really annoying and causing me great frustration. We have passwords which are very long and have numeric and alpha and symbol characters. They are easy to type wrong. As a developer, my workstation has been secured by other means. I wish to make use of "Remember Password" so that I can more quickly DO MY WORK. For months now, whenever our network connections were severed but we were connected already, the next time we tried to connect, the freakin password would be cleared out. This is like Alzheimer's Disease. So, I've learned not to attempt to connect again or execute queries or navigate around in the property tree. I just wait until transient network problem goes away. Then I make my next connection, of course I have to re-type this incredibly long password again, RE-check the "Remember Password" box, get connected, then quit Sql Server Management Studio. This seems to be the only way for it to truely REMEMBER it. Then I restart Sql Server Management Studio, reconnect, and voila, the password has already been filled in for me. NOW, however things are different. There are NO network transient problems. Instead what we have going on here is more like a child with Attention Deficit Disorder. SQL Server Management Studio is FORCING me to retype the password upon every NEW execution. I swear, sometimes when I encounter this problem it totally removes my ability to perform my work. Instead, I picture grabbing the developers who were responsible for making this tool by the neck and like a bobble-head doll, shake them until their head's roll off. That's how frustrating this problem has become for me. Of course, there's going to be some people who read this and chuckle.. well.. it is kind of funny how I've described my frustrations, but really I'd like to SOLVE the problem somehow without having to read ten tons of documentation somewhere ridden with superfluous jargon written by someone who'd rather spread words in a flower garden than get to the freakin' point. Smile Does anyone know how to solve this problem? hmmm... perhaps I should change the password to an empty string? Yeah, that would be appropriate for this problem where Sql Server Management Studio has a zero memory retention skill (ADD), but.. oh... lest we forget, that would cause a security risk now wouldn't it?

Could you please file a defect report for this on http://connect.microsoft.com/sqlserver? Issues reported on the Connect site are automatically ported into our internal issue tracking system so we don't lose any of the information you provide there.

We run in a Windows Domain here at work, so for our day-to-day work we almost universally use Windows Authentication logins and we never have to explicitly provide a password to SQL Server. If you are running in a Windows Domain, IMHO that's the easiest workaround for your problem. This is also the safest route with respect to security - any saved password is a potential security threat. Note that even in workgroup environments you can use Windows Authentication with local Windows logins if Management Studio is running on the same machine as the server.

As another work-around to the problem, you can save off a copy of your local c:\Documents and Settings\{you}\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat file. When management studio overwrites your saved password with an empty string like you describe, you could close management studio and then copy your backup mru.dat file over the more recent one. This will reset the saved settings of the connection dialog and other "most recently used" items in the UI to their saved values.

Management Studio does encrypt saved passwords, but no encryption is unbreakable. Be sure to restrict access to your saved mru.dat file to help prevent unauthorized access to your server.

Hope this helps,

Steve

|||

For the sake of followup I will mark thread as sticky.

Joe

Have you reported in the connect site as per Steve's reference?

|||

I actually don't understand, even as long as the description is, because I don't see this behavior at all.

Let me put in some very simple and straightforward things, as you've asked for.

Open Registered Server, create a new registration, check the save password box, and save the registration. From that point forward, you can ALWAYS right click on a registered server and select Connect | New Query or Connect | Object Explorer. I have NEVER seen it lose one of these passwords for any reason and I've done this in over 100 different customer environments, spanning a couple hundred different workstations.

Now, to the other part. If you are launching a query window from the object browser, the server has to be highlighted for SSMS to have a valid context to launch the query window against. If you launch a query window by using the New Query button and you get a dialog box to login, then it could not find a context, which means that you didn't have the server or a node underneath the server highlighted when you hit the button.

As far as the Remember Password checkbox in the connect dialog goes, I've never used it and have no plans at all to ever use it. I save everything in the Resgistered Servers, so I can always get to what I need without using this piece of the Connect dialog.

So, you wanted a valid workaround for any situation whatsoever, here it is. Use the Regsitered Servers task pane. If you have a query window open when you lose the connection, launch a new query window from the Registered Servers task pane, and then copy/paste the contents of the query window into the new one you just launched. It isn't pretty, but it will work 100% of the time.

|||This guy is completely right.

Let me explain how I first got to this forum.

For the last two years of using SQL Server Management Studio I have constantly been asked for my password whenever I leave my home and connect my laptop at work, or go home and connect my laptop to my home network.

Today was the breaking point for me, and I decided to type this topic into google and "get lucky".

Voila, here I am, and I can attest to this behavior of SSMS. I believe we're both addressing the issue concerning the login prompt when SSMS loads--not the "Registered Servers" pane.

It just behave like a kid with ADD and this behavior is so annoying it makes me pull my hair out and want to use Enterprise Manager, which I thought I would never say, but its true. At least EM saved my passwords...

The context switching is also very annoying.

I could rant for days about the UI fricition in SSMS, such as how the tabbed document layout's file names are so narrow in width that file names become unreadable, the MDI environment forces me to play the "resize window game", and how the summary name column gets resized to default every time you view a new object in the object explorer, but I'll save those bits for another thread.

|||

Here here!

I've had this problem myself ever since I started using SSMS. It's really obnoxious, because I love pretty much every other feature (except for the pummeling that DTS has undergone, but that's more a beef with SQL than SSMS), but this one bug alone has me very close to switching back to Enterprise Manager.

Any way, if you have managed to come up with a solution to this, I'd love to hear it. For me there doesn't even seem to be any rhyme or reason. It will remember my password for two or three connections, maybe four if I'm particularly luck, then spontaneously forget it again. And what's really awful is I'm regularly connecting to six or so different SQL servers, each with long, very strong passwords, that I have to go look up every third or so time I connect to them. I've just been dealing with it until today, when I finally broke down and decided that this was a stupid enough bug that there simply must be an easy fix for it. And after five pages of Google search results, I've drawn the conclusion that a lot of people seem to have this problem, but nobody has a fix for it.

Attention MS: Please please please please please fix this bug and release a patch!

|||Well, you can't use Enterprise Manager. It does not work against SQL Server 2005 instances. Don't know on the connection dialog when you launch SSMS. The very first thing that I configure is to launch SSMS into a blank environment so that I can choose what I want to do from there instead of always launching a query window. As for a workaround, that's 3 posts up, use the Registered Servers task pane.|||

Or Microsoft could just fix SSMS...

"Remember Password" feature behaves like child with Attention Deficit Disorder

In Sql Server Management Studio, when you connect to a server using SQL Server authentication, there is a checkbox "Remember Password". This is really really annoying and causing me great frustration. We have passwords which are very long and have numeric and alpha and symbol characters. They are easy to type wrong. As a developer, my workstation has been secured by other means. I wish to make use of "Remember Password" so that I can more quickly DO MY WORK. For months now, whenever our network connections were severed but we were connected already, the next time we tried to connect, the freakin password would be cleared out. This is like Alzheimer's Disease. So, I've learned not to attempt to connect again or execute queries or navigate around in the property tree. I just wait until transient network problem goes away. Then I make my next connection, of course I have to re-type this incredibly long password again, RE-check the "Remember Password" box, get connected, then quit Sql Server Management Studio. This seems to be the only way for it to truely REMEMBER it. Then I restart Sql Server Management Studio, reconnect, and voila, the password has already been filled in for me. NOW, however things are different. There are NO network transient problems. Instead what we have going on here is more like a child with Attention Deficit Disorder. SQL Server Management Studio is FORCING me to retype the password upon every NEW execution. I swear, sometimes when I encounter this problem it totally removes my ability to perform my work. Instead, I picture grabbing the developers who were responsible for making this tool by the neck and like a bobble-head doll, shake them until their head's roll off. That's how frustrating this problem has become for me. Of course, there's going to be some people who read this and chuckle.. well.. it is kind of funny how I've described my frustrations, but really I'd like to SOLVE the problem somehow without having to read ten tons of documentation somewhere ridden with superfluous jargon written by someone who'd rather spread words in a flower garden than get to the freakin' point. Smile Does anyone know how to solve this problem? hmmm... perhaps I should change the password to an empty string? Yeah, that would be appropriate for this problem where Sql Server Management Studio has a zero memory retention skill (ADD), but.. oh... lest we forget, that would cause a security risk now wouldn't it?

Could you please file a defect report for this on http://connect.microsoft.com/sqlserver? Issues reported on the Connect site are automatically ported into our internal issue tracking system so we don't lose any of the information you provide there.

We run in a Windows Domain here at work, so for our day-to-day work we almost universally use Windows Authentication logins and we never have to explicitly provide a password to SQL Server. If you are running in a Windows Domain, IMHO that's the easiest workaround for your problem. This is also the safest route with respect to security - any saved password is a potential security threat. Note that even in workgroup environments you can use Windows Authentication with local Windows logins if Management Studio is running on the same machine as the server.

As another work-around to the problem, you can save off a copy of your local c:\Documents and Settings\{you}\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat file. When management studio overwrites your saved password with an empty string like you describe, you could close management studio and then copy your backup mru.dat file over the more recent one. This will reset the saved settings of the connection dialog and other "most recently used" items in the UI to their saved values.

Management Studio does encrypt saved passwords, but no encryption is unbreakable. Be sure to restrict access to your saved mru.dat file to help prevent unauthorized access to your server.

Hope this helps,

Steve

|||

For the sake of followup I will mark thread as sticky.

Joe

Have you reported in the connect site as per Steve's reference?

|||

I actually don't understand, even as long as the description is, because I don't see this behavior at all.

Let me put in some very simple and straightforward things, as you've asked for.

Open Registered Server, create a new registration, check the save password box, and save the registration. From that point forward, you can ALWAYS right click on a registered server and select Connect | New Query or Connect | Object Explorer. I have NEVER seen it lose one of these passwords for any reason and I've done this in over 100 different customer environments, spanning a couple hundred different workstations.

Now, to the other part. If you are launching a query window from the object browser, the server has to be highlighted for SSMS to have a valid context to launch the query window against. If you launch a query window by using the New Query button and you get a dialog box to login, then it could not find a context, which means that you didn't have the server or a node underneath the server highlighted when you hit the button.

As far as the Remember Password checkbox in the connect dialog goes, I've never used it and have no plans at all to ever use it. I save everything in the Resgistered Servers, so I can always get to what I need without using this piece of the Connect dialog.

So, you wanted a valid workaround for any situation whatsoever, here it is. Use the Regsitered Servers task pane. If you have a query window open when you lose the connection, launch a new query window from the Registered Servers task pane, and then copy/paste the contents of the query window into the new one you just launched. It isn't pretty, but it will work 100% of the time.

|||This guy is completely right.

Let me explain how I first got to this forum.

For the last two years of using SQL Server Management Studio I have constantly been asked for my password whenever I leave my home and connect my laptop at work, or go home and connect my laptop to my home network.

Today was the breaking point for me, and I decided to type this topic into google and "get lucky".

Voila, here I am, and I can attest to this behavior of SSMS. I believe we're both addressing the issue concerning the login prompt when SSMS loads--not the "Registered Servers" pane.

It just behave like a kid with ADD and this behavior is so annoying it makes me pull my hair out and want to use Enterprise Manager, which I thought I would never say, but its true. At least EM saved my passwords...

The context switching is also very annoying.

I could rant for days about the UI fricition in SSMS, such as how the tabbed document layout's file names are so narrow in width that file names become unreadable, the MDI environment forces me to play the "resize window game", and how the summary name column gets resized to default every time you view a new object in the object explorer, but I'll save those bits for another thread.

|||

Here here!

I've had this problem myself ever since I started using SSMS. It's really obnoxious, because I love pretty much every other feature (except for the pummeling that DTS has undergone, but that's more a beef with SQL than SSMS), but this one bug alone has me very close to switching back to Enterprise Manager.

Any way, if you have managed to come up with a solution to this, I'd love to hear it. For me there doesn't even seem to be any rhyme or reason. It will remember my password for two or three connections, maybe four if I'm particularly luck, then spontaneously forget it again. And what's really awful is I'm regularly connecting to six or so different SQL servers, each with long, very strong passwords, that I have to go look up every third or so time I connect to them. I've just been dealing with it until today, when I finally broke down and decided that this was a stupid enough bug that there simply must be an easy fix for it. And after five pages of Google search results, I've drawn the conclusion that a lot of people seem to have this problem, but nobody has a fix for it.

Attention MS: Please please please please please fix this bug and release a patch!

|||Well, you can't use Enterprise Manager. It does not work against SQL Server 2005 instances. Don't know on the connection dialog when you launch SSMS. The very first thing that I configure is to launch SSMS into a blank environment so that I can choose what I want to do from there instead of always launching a query window. As for a workaround, that's 3 posts up, use the Registered Servers task pane.|||

Or Microsoft could just fix SSMS...

Thursday, March 8, 2012

"Key cannot be null. Parameter name: key"

We are using forms authentication with SSRS2005 and we are able to access Report Manager (http://servername/reports) and Reportserver (http://servername/reportserver). The problem we are having is every time we add a user to the Content Manager or the Publisher role. The user is able to login and reach the Report Manager but no folder is showing up and also we have the following error message : "Key cannot be null. Parameter name: key".

We removed users from the Content Manager and Publisher Roles and they are able to reach report manager and see the folders. This only happens with report manager. everything works fine with reportserver(http://servername/reportserver).

Any idea why we're getting an error message when trying to assign the Content Manager and publisher Roles to a user.

here is the error log from ReportServerWebApp :

aspnet_wp!ui!1!3/27/2007-16:38:49:: e ERROR: Key cannot be null.
Parameter name: key
aspnet_wp!ui!1!3/27/2007-16:38:49:: e ERROR: HTTP status code --> 500
-Details--
System.ArgumentNullException: Key cannot be null.

Parameter name: key

at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)

at System.Collections.Hashtable.Add(Object key, Object value)

at Microsoft.ReportingServices.UI.BasePermissions.ReadPermissions(String[] permissions)

at Microsoft.ReportingServices.UI.Permissions.GetPermissions()

at Microsoft.ReportingServices.UI.Permissions.CurrentUser(String itemPath)

at Microsoft.ReportingServices.UI.FolderPage.Page_Init(Object sender, EventArgs e)

at System.EventHandler.Invoke(Object sender, EventArgs e)

at System.Web.UI.Control.OnInit(EventArgs e)

at System.Web.UI.Page.OnInit(EventArgs e)

at System.Web.UI.Control.InitRecursive(Control namingContainer)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
aspnet_wp!ui!1!3/27/2007-16:38:49:: e ERROR: Exception in ShowErrorPage: System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at Microsoft.ReportingServices.UI.ReportingPage.ShowErrorPage(String errMsg) at at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at Microsoft.ReportingServices.UI.ReportingPage.ShowErrorPage(String errMsg)

Thanks!

chi

Hi

Check the following post out, it may help

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=327150&SiteID=1

|||

i checked the link, hmmm... did not work. any other suggestions.

chi

"Key cannot be null. Parameter name: key"

We are using forms authentication with SSRS2005 and we are able to access Report Manager (http://servername/reports) and Reportserver (http://servername/reportserver). The problem we are having is every time we add a user to the Content Manager or the Publisher role. The user is able to login and reach the Report Manager but no folder is showing up and also we have the following error message : "Key cannot be null. Parameter name: key".

We removed users from the Content Manager and Publisher Roles and they are able to reach report manager and see the folders. This only happens with report manager. everything works fine with reportserver(http://servername/reportserver).

Any idea why we're getting an error message when trying to assign the Content Manager and publisher Roles to a user.

here is the error log from ReportServerWebApp :

aspnet_wp!ui!1!3/27/2007-16:38:49:: e ERROR: Key cannot be null.
Parameter name: key
aspnet_wp!ui!1!3/27/2007-16:38:49:: e ERROR: HTTP status code --> 500
-Details--
System.ArgumentNullException: Key cannot be null.

Parameter name: key

at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)

at System.Collections.Hashtable.Add(Object key, Object value)

at Microsoft.ReportingServices.UI.BasePermissions.ReadPermissions(String[] permissions)

at Microsoft.ReportingServices.UI.Permissions.GetPermissions()

at Microsoft.ReportingServices.UI.Permissions.CurrentUser(String itemPath)

at Microsoft.ReportingServices.UI.FolderPage.Page_Init(Object sender, EventArgs e)

at System.EventHandler.Invoke(Object sender, EventArgs e)

at System.Web.UI.Control.OnInit(EventArgs e)

at System.Web.UI.Page.OnInit(EventArgs e)

at System.Web.UI.Control.InitRecursive(Control namingContainer)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
aspnet_wp!ui!1!3/27/2007-16:38:49:: e ERROR: Exception in ShowErrorPage: System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at Microsoft.ReportingServices.UI.ReportingPage.ShowErrorPage(String errMsg) at at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
at Microsoft.ReportingServices.UI.ReportingPage.ShowErrorPage(String errMsg)

Thanks!

chi

Hi

Check the following post out, it may help

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=327150&SiteID=1

|||

i checked the link, hmmm... did not work. any other suggestions.

chi

Thursday, February 16, 2012

<asp:SqlDataSource> need a look over to see If I am writing this correctly.

This is a subset question of one of my other threads, the gist is while using forms authentication, I am trying to enter additional information into another table on the same db as the aspnet_membership tables. I think I need an <asp:SqlDataSource> to do this because it is about the only thing left I haven't tried to get this code to work so any help is appreciated. Environment: sql server 2000, windows server 2003, asp.net 2.0, vb, no GUI

<ASP:SqlDataSource id="addedInfo" ConnectionString="<%$ ConnectionStrings:SqlServerConnection %>" InsertCommand="INSERT INTO addInfo(username,email,company,firstname,lastname,phone) VALUES (@.username,@.email,@.company,@.firstname,@.lastname,@.phone)" runat="server" />

looking over some of my books and online it says in the connectionStrings that it is supposed to be the database name that goes next to the : but when I try that I get an error that it is looking for the name of the connection string, so I enter the name of the connection string (as above) and nothing happens, which is basically the ongoing event with this whole problem, the form fields (username, email, password) that go into the aspnet_membership tables just fine, I don't have any problems with those, it is getting the additional information into another table that has been stalling me the whole time.

So does this sqldatasource look right? Any help is appreciated.

this is the full page of register.aspx

<%@. Page Explicit="true" debug="true" language="vb" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SqlClient" %>
<%@. Import Namespace="System.Data.Mail" %>
<%@. Import Namespace="System.Net.Mail" %>

<script runat="server">

Public Sub CreateUser_OnClick(sender As Object, args As EventArgs)
Dim result As MembershipCreateStatus
Try
' Create new user.

Dim newUser As MembershipUser
If Membership.RequiresQuestionAndAnswer Then
newUser = Membership.CreateUser(UsernameTextbox.Text,PasswordTextbox.Text,EmailTextbox.Text,PasswordQuestionTextbox.Text, PasswordAnswerTextbox.Text,false,result)
Else
newUser = Membership.CreateUser(UsernameTextbox.Text,PasswordTextbox.Text,EmailTextbox.Text)
End If


Response.Redirect("login.aspx")

Catch e As MembershipCreateUserException
Msg.Text = GetErrorMessage(e.StatusCode)
Catch e As HttpException
Msg.Text = e.Message
End Try
End Sub

Public Function GetErrorMessage(status As MembershipCreateStatus) As String

Select Case status
Case MembershipCreateStatus.DuplicateUserName
Return "Username already exists. Please enter a different user name."

Case MembershipCreateStatus.DuplicateEmail
Return "A username for that e-mail address already exists. Please enter a different e-mail address."

Case MembershipCreateStatus.InvalidPassword
Return "The password provided is invalid. Please enter a valid password value."

Case MembershipCreateStatus.InvalidEmail
Return "The e-mail address provided is invalid. Please check the value and try again."

Case MembershipCreateStatus.InvalidAnswer
Return "The password retrieval answer provided is invalid. Please check the value and try again."

Case MembershipCreateStatus.InvalidQuestion
Return "The password retrieval question provided is invalid. Please check the value and try again."

Case MembershipCreateStatus.InvalidUserName
Return "The user name provided is invalid. Please check the value and try again."

Case MembershipCreateStatus.ProviderError
Return "The authentication provider Returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator."

Case MembershipCreateStatus.UserRejected
Return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator."

Case Else
Return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."
End Select
End Function

</script>

<form runat="server" id="form1">
<h3>Create New User</h3>

<asp:Label id="Msg" ForeColor="maroon" runat="server" /><BR>

<table CellPadding="3" border="0">
<tr>
<td><span class="style5">Username:</span></td>
<td><asp:Textbox id="UsernameTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="UsernameRequiredValidator" runat="server"
ControlToValidate="UserNameTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Password:</span></td>
<td><asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
ControlToValidate="PasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Confirm Password:</span></td>
<td><asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" />
<asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ControlToCompare="PasswordTextBox"
ErrorMessage="Confirm password must match password." /> </td>
</tr>
<tr>
<td><span class="style5">Email Address:</span></td>
<td><asp:Textbox id="EmailTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="EmailRequiredValidator" runat="server"
ControlToValidate="EmailTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>


<% If Membership.RequiresQuestionAndAnswer Then %>

<tr>
<td>Password Question:</td>
<td><asp:Textbox id="PasswordQuestionTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordQuestionRequiredValidator" runat="server"
ControlToValidate="PasswordQuestionTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password Answer:</td>
<td><asp:Textbox id="PasswordAnswerTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordAnswerRequiredValidator" runat="server"
ControlToValidate="PasswordAnswerTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<% End If %>
</table>
<!-- so much trouble below! -->
<table cellpadding="3" cellspacing="0">
<tr>
<td width="122"><span class="style5">Company:</span>
</td>
<td width="144"><asp:Textbox id="CompanyTextbox" runat="server" /></td>
<td width="387"><asp:RequiredFieldValidator id="CompanyValidator" runat="server" ControlToValidate="CompanyTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">First Name:</span></td>
<td><asp:Textbox id="FirstNameTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="FirstNameValidator" runat="server" ControlToValidate="FirstNameTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Last Name:</span> </td>
<td><asp:Textbox id="LastNameTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="LastNameValidator" runat="server" ControlToValidate="LastNameTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Phone Number:</span> </td>
<td><asp:Textbox id="PhoneTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PhoneValidator" runat="server" ControlToValidate="PhoneTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" />
<ASP:SqlDataSource id="addedInfo" ConnectionString="<%$ ConnectionStrings:SqlElectron %>" InsertCommand="INSERT INTO addInfo(username,email,company,firstname,lastname,phone) VALUES (UserNameTextbox,EmailTextbox,CompanyTextbox,FirstNameTextbox,LastNameTextbox,PhoneTextbox)" runat="server" />
</td>
</tr>
<tr>
<td></td>
<td><asp:Button id="CreateUserButton" CssClass="style5" Text="Create User" OnClick="CreateUser_OnClick" runat="server" /></td>
</tr>
</table>
</form>

From some tests right now the entire code is just being ignored. I've tried to break this by intentionally adding fields that don't exist into the add so that it would return (I forget what it is precisily called) the error where it says that the fields being entered do not match the database. As always any help is appreciated.

|||

For a minute there thought I actually figured out what I didn't do, I didn't add the DataSourceID to the textboxes, so I added it and nothing happens still the same problem :( So below is the current version of the code:

<form runat="server" id="form1">
<h3>Create New User</h3>

<asp:Label id="Msg" ForeColor="maroon" runat="server" /><BR>

<table CellPadding="3" border="0">
<tr>
<td><span class="style5">Username:</span></td>
<td><asp:Textbox id="UsernameTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="UsernameRequiredValidator" runat="server"
ControlToValidate="UserNameTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Password:</span></td>
<td><asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
ControlToValidate="PasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Confirm Password:</span></td>
<td><asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" />
<asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ControlToCompare="PasswordTextBox"
ErrorMessage="Confirm password must match password." /> </td>
</tr>
<tr>
<td><span class="style5">Email Address:</span></td>
<td><asp:Textbox id="EmailTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="EmailRequiredValidator" runat="server"
ControlToValidate="EmailTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>


<% If Membership.RequiresQuestionAndAnswer Then %>

<tr>
<td>Password Question:</td>
<td><asp:Textbox id="PasswordQuestionTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordQuestionRequiredValidator" runat="server"
ControlToValidate="PasswordQuestionTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password Answer:</td>
<td><asp:Textbox id="PasswordAnswerTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordAnswerRequiredValidator" runat="server"
ControlToValidate="PasswordAnswerTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<% End If %>
</table>
<!-- so much trouble below! -->
<table cellpadding="3" cellspacing="0">
<tr>
<td width="122"><span class="style5">Company:</span>
</td>
<td width="144"><asp:Textbox id="CompanyTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td width="387"><asp:RequiredFieldValidator id="CompanyValidator" runat="server" ControlToValidate="CompanyTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">First Name:</span></td>
<td><asp:Textbox id="FirstNameTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="FirstNameValidator" runat="server" ControlToValidate="FirstNameTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Last Name:</span> </td>
<td><asp:Textbox id="LastNameTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="LastNameValidator" runat="server" ControlToValidate="LastNameTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Phone Number:</span> </td>
<td><asp:Textbox id="PhoneTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="PhoneValidator" runat="server" ControlToValidate="PhoneTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" />
<asp:SqlDataSource id="addedInfo" ConnectionString="<%$ ConnectionStrings:SqlElectron %>" InsertCommand="INSERT INTO addInfo(username,email,company,firstname,lastname,phone) VALUES (UserNameTextbox,EmailTextbox,CompanyTextbox,FirstNameTextbox,LastNameTextbox,PhoneTextbox)" runat="server" />
</td>
</tr>
<tr>
<td></td>
<td><asp:Button id="CreateUserButton" CssClass="style5" Text="Create User" OnClick="CreateUser_OnClick" runat="server" /></td>
</tr>
</table>
</form>

any help is appreciated. I've been working on this problem now for the better part of two weeks, and I am simply out of ideas as to the problem.

|||

For a minute there thought I actually figured out what I didn't do, I didn't add the DataSourceID to the textboxes, so I added it and nothing happens still the same problem :( So below is the current version of the code:

<form runat="server" id="form1">
<h3>Create New User</h3>

<asp:Label id="Msg" ForeColor="maroon" runat="server" /><BR>

<table CellPadding="3" border="0">
<tr>
<td><span class="style5">Username:</span></td>
<td><asp:Textbox id="UsernameTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="UsernameRequiredValidator" runat="server"
ControlToValidate="UserNameTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Password:</span></td>
<td><asp:Textbox id="PasswordTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordRequiredValidator" runat="server"
ControlToValidate="PasswordTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Confirm Password:</span></td>
<td><asp:Textbox id="PasswordConfirmTextbox" runat="server" TextMode="Password" /></td>
<td><asp:RequiredFieldValidator id="PasswordConfirmRequiredValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" />
<asp:CompareValidator id="PasswordConfirmCompareValidator" runat="server"
ControlToValidate="PasswordConfirmTextbox" ForeColor="red"
Display="Static" ControlToCompare="PasswordTextBox"
ErrorMessage="Confirm password must match password." /> </td>
</tr>
<tr>
<td><span class="style5">Email Address:</span></td>
<td><asp:Textbox id="EmailTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="EmailRequiredValidator" runat="server"
ControlToValidate="EmailTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>


<% If Membership.RequiresQuestionAndAnswer Then %>

<tr>
<td>Password Question:</td>
<td><asp:Textbox id="PasswordQuestionTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordQuestionRequiredValidator" runat="server"
ControlToValidate="PasswordQuestionTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td>Password Answer:</td>
<td><asp:Textbox id="PasswordAnswerTextbox" runat="server" /></td>
<td><asp:RequiredFieldValidator id="PasswordAnswerRequiredValidator" runat="server"
ControlToValidate="PasswordAnswerTextbox" ForeColor="red"
Display="Static" ErrorMessage="Required" /></td>
</tr>
<% End If %>
</table>
<!-- so much trouble below! -->
<table cellpadding="3" cellspacing="0">
<tr>
<td width="122"><span class="style5">Company:</span>
</td>
<td width="144"><asp:Textbox id="CompanyTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td width="387"><asp:RequiredFieldValidator id="CompanyValidator" runat="server" ControlToValidate="CompanyTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">First Name:</span></td>
<td><asp:Textbox id="FirstNameTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="FirstNameValidator" runat="server" ControlToValidate="FirstNameTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Last Name:</span> </td>
<td><asp:Textbox id="LastNameTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="LastNameValidator" runat="server" ControlToValidate="LastNameTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" /></td>
</tr>
<tr>
<td><span class="style5">Phone Number:</span> </td>
<td><asp:Textbox id="PhoneTextbox" runat="server" DataSourceID="addedInfo" /></td>
<td><asp:RequiredFieldValidator id="PhoneValidator" runat="server" ControlToValidate="PhoneTextbox" ForeColor="red" Display="Static" ErrorMessage="Required" />
<asp:SqlDataSource id="addedInfo" ConnectionString="<%$ ConnectionStrings:SqlElectron %>" InsertCommand="INSERT INTO addInfo(username,email,company,firstname,lastname,phone) VALUES (UserNameTextbox,EmailTextbox,CompanyTextbox,FirstNameTextbox,LastNameTextbox,PhoneTextbox)" runat="server" />
</td>
</tr>
<tr>
<td></td>
<td><asp:Button id="CreateUserButton" CssClass="style5" Text="Create User" OnClick="CreateUser_OnClick" runat="server" /></td>
</tr>
</table>
</form>

any help is appreciated. I've been working on this problem now for the better part of two weeks, and I am simply out of ideas as to the problem.

|||

Public Sub CreateUser_OnClick(sender As Object, args As EventArgs)
Dim result As MembershipCreateStatus
Try
' Create new user.

Dim newUser As MembershipUser
If Membership.RequiresQuestionAndAnswer Then
newUser = Membership.CreateUser(UsernameTextbox.Text,PasswordTextbox.Text,EmailTextbox.Text,PasswordQuestionTextbox.Text, PasswordAnswerTextbox.Text,false,result)
Else
newUser = Membership.CreateUser(UsernameTextbox.Text,PasswordTextbox.Text,EmailTextbox.Text)
End If

dim conn as new sqlconnection(system.configuration.configurationmanager.connectionstrings("SqlElectron").connectionstring)

dim cmd as new sqlcommand("INSERT INTO addInfo(username,email,company,firstname,lastname,phone) VALUES (@.UserNameTextbox,@.EmailTextbox,@.CompanyTextbox,@.FirstNameTextbox,@.LastNameTextbox,@.PhoneTextbox)",conn)

cmd.parameters.add("@.UserNameTextbox",varchar).value=UsernameTextbox.Text

cmd.parameters.add("@.EmailTextbox",varchar).value=EmailTextbox.Text

{Add rest of fields here}

conn.open

cmd.executenonquery

conn.close

Response.Redirect("login.aspx")

Catch e As MembershipCreateUserException
Msg.Text = GetErrorMessage(e.StatusCode)
Catch e As HttpException
Msg.Text = e.Message
End Try
End Sub

|||

First thanks for the help moley

second the code errors out with two errors first it needs varchar set to a value and the connection string it saysSystem.NullReferenceException: Object reference not set to an instance of an object.

I'm working on a variant of what you posted and Ill post it as soon as I get it done with whether it works or not.

|||yep it gives me the beginning of the findcontrol loop logic error that I have in one of my other threadshttp://forums.asp.net/2/1381460/ShowThread.aspx . basically

No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type.

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.ArgumentException: No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type.

Source Error:

Line 37: Line 38: SQLConn.Open()Line 39: cmd.ExecuteNonQueryLine 40: SQLConn.CloseLine 41:


Source File:C:\Inetpub\wwwroot\login\register.aspx Line:39

It can never find the value of the textboxes because the textboxes get wiped out in the process of the membership being made, If I try to put this type of code before the membership stuff it will not find anything, If I use findcontrol() to try and extract the value it will return with nothing and thus I return to my two week+ nightmare of trying to get this to work. I assumed since I needed to trap the info that I could use the <asp:SqlDataSource to do that and then send it's insert seperatly but I guess that doesn't work.

For those forum members that have a custom registration page (basically something that adds more fields than what is in the CreateUserWizard) how do you enter those fields? I honest to gawd don't know what I am missing but basically I have tried every code example I could come across, I've tried everything other forumers have tried, I just have no idea what I am missing or not doing? I can enter the basic forms data fine (username, email, password) that enters the aspnet_membership tabels fine but I can get nothing into the addInfo table that I have in the same database. Any help is appreciated and thanks to everyone who has been helping me.

|||

The big error:

You forgot to supply .Text when assigning the value to one of the parameters.

First error:

Change:

cmd.parameters.add("@.UserNameTextbox",varchar).value=UsernameTextbox.Text

to:

cmd.Parameters.Add("@.UserNameTextbox",sqldbtype.varchar).Value=UsernameTextbox.Text

varchar isn't a variable, it's a value from the system.data.sqldbtype enumeration.

--

Second Error:

Please post your web.config file (Please make sure you remove any passwords by using XXXXXXXX instead of the real password before posting).

|||

<configuration>
<appSettings>
<add key="ConnectionString" value="DataSource=mew@.mew.com;UID=bark;pwd=xxxxxxxxx" />
<add key="ConnectionString" value="Server=xxx.xxx.xxx.xxx;database=customerlogin;UID=yyyyyyyy;pwd=xxxxxxxx;Trusted_Connection=True" />
</appSettings>
<connectionStrings>
<add name="SqlServerConnection" connectionString="Server=xxx.xxx.xxx.xxx;database=customerlogin;UID=yyyyyyyy;pwd=xxxxxxxx;Trusted_Connection=True" />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=xxx.xxx.xxx.xxx;Integrated Security=SSPI;Initial Catalog=customerlogin;UID=yyyyyyyyy;pwd=xxxxxxxxx;Trusted_Connection=True" />
</connectionStrings>
<location path="lock">
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
<system.web>
<authentication mode="Forms">
<forms cookieless="AutoDetect" defaultUrl="~\lock\library.aspx" loginUrl="../login.aspx" name=".ASPXAUTH" />
</authentication>
</system.web>
<system.web>
<membership defaultProvider="MyProvider">
<providers>
<add name="MyProvider" type="System.Web.Security.SqlMembershipProvider" passwordFormat="Clear" connectionStringName="LocalSqlServer" requiresQuestionAndAnswer="false" />
</providers>
</membership>
</system.web>
<system.web>
<profile enabled="true">
<properties>
<add name="company" type="String" />
<add name="firstname" type="String"/>
<add name="lastname" type="String"/>
<add name="phone" type="String" />
</properties>
</profile>
</system.web>
</location>
</configuration>

The highlighted UID's are the same and thus consequently the passwords are the same. I removed the SqlElectron from the previous examples since making a second account didn't help the matter and have gone back to alternating between the SqlServerConnection and LocalSqlServer connections depending on what variable I am testing. Thanks for the help Motley.

|||

Here:

PrivateFunction SuperFindControl(ByVal ctrlAsString,OptionalByVal basectrlAs Control =Nothing)As Control

If basectrlIsNothingThen

basectrl = Page

EndIf

If basectrl.Controls.Count > 0Then

ForEach cAs ControlIn basectrl.Controls

If c.IDIsNotNothingAndAlso c.ID.ToLower = ctrl.ToLowerThen

Return c

Else

If c.Controls.Count > 0Then

Dim c2As Control = SuperFindControl(ctrl, c)

IfNot c2IsNothingThen

Return c2

EndIf

EndIf

EndIf

Next

EndIf

ReturnNothing

EndFunction

Now you can reference your control as SuperFindControl("txtCompanyTextBox") anywhere in your code -- but it will only return the first one it finds with that id if you have more than one.

|||

Motley:

The big error:

You forgot to supply .Text when assigning the value to one of the parameters.

First error:

Change:

cmd.parameters.add("@.UserNameTextbox",varchar).value=UsernameTextbox.Text

to:

cmd.Parameters.Add("@.UserNameTextbox",sqldbtype.varchar).Value=UsernameTextbox.Text

varchar isn't a variable, it's a value from the system.data.sqldbtype enumeration.

--

Second Error:

Please post your web.config file (Please make sure you remove any passwords by using XXXXXXXX instead of the real password before posting).

W00T it works! The highlighted ontop of whatever other changes I've made(ill have to break the page to find out what actually did it) have worked, I get the additional info in the new table and everything works well, Thanks a lot Motley you have been a lifesaver, and more than likely helped me keep my job. I would give you a hug but we dont know each other well enough lol, so

/e handshake

Thanks a lot.

|||

Now only one problem left to fix, but now I can close three threads that were all related to each other.

Login.aspx I'm looking at you next!

Thanks again Motley.

|||

Given your web.config file, the connection should be:

dim conn as new sqlconnection(system.configuration.configurationmanager.connectionstrings("LocalSqlServer").connectionstring)