xlabs 0 Denunciar post Postado Setembro 17, 2004 Já tentei de tudo qto é maneira, mas nao rola. É uma página para inserir usuários..o banco, os textbox já chequei tudo e não acho o %%$ do erro. SQL Server does not exist or access denied ASP [/tr][tr]<%@ Page Language="VB" %><script runat="server"> Function AddUser(ByVal userName As String, ByVal userPassword As String) As Integer Dim connectionString As String = _ "server='localhost'; trusted_connection=true; Database='Orders'" Dim sqlConnection As System.Data.SqlClient.SqlConnection = _ New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "INSERT INTO [users] ([userName], [userPassword]) " & _ "VALUES (@UserName, @UserPassword)" Dim sqlCommand As System.Data.SqlClient.SqlCommand = _ New System.Data.SqlClient.SqlCommand(queryString, sqlConnection) sqlCommand.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar).Value = _ userName sqlCommand.Parameters.Add("@UserPassword", System.Data.SqlDbType.VarChar).Value = _ userPassword Dim rowsAffected As Integer = 0 sqlConnection.Open Try rowsAffected = sqlCommand.ExecuteNonQuery Finally sqlConnection.Close End Try Return rowsAffected End Function Sub Button1_Click(sender As Object, e As EventArgs) If AddUser(txtUserName.Text, txtUserPassword.Text) > 0 Message.Text = "Cadastrado" Else Message.Text = "Erro" End If End Sub </script> <html> <head> </head> <body bottommargin="0" leftmargin="1" topmargin="1" rightmargin="0"> <form style="BACKGROUND-COLOR: white" runat="server"> <p> <font face="Verdana"><strong>Insere Usuário</strong></font> </p> <p> <asp:Label id="Label1" runat="server" font-names="Verdana" font-size="Smaller">UserName</asp:Label> <asp:TextBox id="txtUserName" runat="server"></asp:TextBox> </p> <p> <asp:Label id="Label2" runat="server" font-names="Verdana" font-size="Smaller">UserPassword:</asp:Label> <asp:TextBox id="txtUserPassword" runat="server" TextMode="Password"></asp:TextBox> </p> <p> <asp:Label id="Message" runat="server" font-names="Verdana" font-size="Smaller"></asp:Label> </p> <p> <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Cadastrar"></asp:Button> </p> <!-- Insert content here --> </form> </body> </html> [/tr] Valeu Abraços Compartilhar este post Link para o post Compartilhar em outros sites
Fernando B. 0 Denunciar post Postado Setembro 18, 2004 Oppsss... =) http://www.imasters.com.br/forum/index.php?showtopic=107327 Um abraço, Fernando Botelho Compartilhar este post Link para o post Compartilhar em outros sites