Showing posts with label connecting. Show all posts
Showing posts with label connecting. Show all posts

Monday, March 26, 2012

New SQLConnection w/ user specifics......

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).

Saturday, February 25, 2012

New domain name - problems connecting

I installed SQL Server 2005 yesterday on a freshly installed Windows 2003 R2
standard server. I installed with mixed-mode authentication and was able to
connect to the database.
The server was then changed to a PDC with a new forest and domain. I am now
unable to connect. What changes do I need to make to Sql Server to get back
up and running.
tia,
Bob M..Refer:
http://support.microsoft.com/kb/910228/en-us#E0WR0ABAAA
Do not change the role of the server after you install SQL Server 2005. For
example, if you install SQL Server 2005 on a member server, do not use the
Dcpromo tool to promote the server to a domain controller. Or, if you
install SQL Server 2005 on a domain controller, do not use Dcpromo to
demote the server to a member server. Changing the role of a server after
you install SQL Server 2005 can result in loss of functionality and is not
supported.
=======
--
>From: "Bob Murdoch" <ram_re_move_5@.erols.com>
>Subject: New domain name - problems connecting
>Date: Thu, 4 May 2006 12:44:16 -0400

>I installed SQL Server 2005 yesterday on a freshly installed Windows 2003
R2
>standard server. I installed with mixed-mode authentication and was able
to
>connect to the database.
>The server was then changed to a PDC with a new forest and domain. I am
now
>unable to connect. What changes do I need to make to Sql Server to get
back
>up and running.
>tia,
>Bob M..
>
>