This actually goes back to another post...I need the user to state which specifics to use when connecting to a server. I have text boxes set up and I need to have thier input placed into the New SqlConnection statement. I have used the below which did not work...
'dim connorthwind as New SQLConnection ("Server=" & strservername & ";UID=" & strUsername & ";PWD=" & strPassword & ";database=master")
See below for my code:
<%@. Page %>
<%@. import Namespace="System.Data.SqlClient" %>
<%@. import Namespace="System.Data" %>
<script runat="server">
Sub Button_Click( s As Object, e As EventArgs )
dim conNorthwind as New SqlConnection( "Server=dbtest1;UID=cbtest;PWD=password3;database=master" )
Dim strInsert As String
Dim cmdInsert As SqlCommand
cmdInsert = New SqlCommand( "sp_password_sec", conNorthwind )
cmdInsert.CommandType = CommandType.StoredProcedure
'cmdINsert.Parameters.Add( "@.loginname", txtname.text )
cmdINsert.Parameters.Add( "@.oldpwd", Password.text )
cmdINsert.Parameters.Add( "@.newpwd", txtnew.text )
conNorthwind.Open()
cmdInsert.ExecuteNonQuery()
conNorthwind.Close()
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="Server">
<h2>Password Change
</h2>
<b>User Name</b>
<br />
<asp:TextBox id="username" Runat="Server"></asp:TextBox>
<p>
<b>Server Name</b>
<br />
<asp:TextBox id="Servername" Runat="Server"></asp:TextBox>
</p>
<p>
<b>Database </b>
<br />
<asp:TextBox id="txtdatabase" Runat="Server"></asp:TextBox>
</p>
<p>
<b>Old Pass</b>
<br />
<asp:TextBox id="Password" Runat="Server"></asp:TextBox>
</p>
<p>
<b>New Pass</b>
<br />
<asp:TextBox id="txtnew" Runat="Server"></asp:TextBox>
</p>
<p>
<asp:Button id="Button1" onclick="Button_Click" Runat="Server" Text="Lookup!"></asp:Button>
</p>
</form>
</body>
</html>
What didn't work? Did you get an error?
Also, this way of connecting is quite unusual, it is a better practice to use the same connection string for everyone for a variety of reasons (eg, to use connection pooling & to maintain the proper security)
|||...I don't think it would be possible for everyone to use the same connection if they are resetting their own pw. If they log on using a functional acct or system acct, it will not allow them to change b/c they are not logged in using their own acct...
|||cbaxter82:
if they are resetting their own pw
What pwd are they changing? If they change their windows pwd or their application pwd it has nothing to do with a sql connection. You should not be adding users to SQL Server, that's a major headache when users come and go and it is a major security breach, too (once a user has a SQL login, they can log in via Excel if they're smart enough! You need to control access to the databse).
No comments:
Post a Comment