Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => Programación Visual Basic => Mensaje iniciado por: Erika Vega en 5 Febrero 2009, 22:27 PM

Título: NO inserta registro en MSSQL server 2000
Publicado por: Erika Vega en 5 Febrero 2009, 22:27 PM
Pues ese es el problema que tengo, no me inserta el registro en SQL server, que estoy haciendo mal.

Código (vb) [Seleccionar]
Private Sub cmdRegister_Click()
Dim registro As String
Dim msg As String
Dim ann As String
Dim Obj As EncriptString
Set Obj = New EncriptString
Dim lNumRegAfect As Long
Dim strSQL As String

Set conectar = New ADODB.Connection
Set registro = New ADODB.Recordset

On Error Resume Next
'Path del fichero Ini
Path_Archivo_Ini = App.Path & "\config.ini"


'Lee los datos y  Les envia el valor por defecto por si no existe
account = Leer_Ini(Path_Archivo_Ini, "user", "sa")
password = Leer_Ini(Path_Archivo_Ini, "pass", "123")

ann = Obj.descifrar(password)


msg = MsgBox("Estas a punto de registrar una cuenta con los siguientes datos: " & vbCrLf _
             & "Nombre de usuario: " & txtNickname & vbCrLf _
             & "Password: " & txtPassword & vbCrLf _
             & "Correo Electronico: " & txtEmail & vbCrLf _
             , vbInformation + vbYesNo, "Info")

If msg = vbYes Then
Set conectar = New ADODB.Connection
Set registro = New ADODB.Recordset

    conectar.Open "PROVIDER=MSDASQL;" & _
                  "driver={SQL Server};" & _
                  "server=(local);" & _
                  "uid=" & account & ";" & _
                  "pwd=" & ann & ";" & _
                  "database=users;"

   
    registro = "INSERT INTO info(id,pwd,mail)" & _
                   "VALUES('" & txtNickname & "', '" & _
                                txtPassword & "', '" & _
                                txtEmail & "')"
   
    conectar.Execute registro, lNumRegAfect
   
    MsgBox "Cuenta registrada satisfactoriamente", vbInformation, "Info"

   MsgBox "Número de registros afectados: " & lNumRegAfect

    conectar.Close

Else
Exit Sub
conectar.Close
registro.Close
Unload Me
End If

End Sub
Título: Re: NO inserta registro en MSSQL server 2000
Publicado por: seba123neo en 6 Febrero 2009, 00:25 AM
Hola, ¿pero te tira error en algun lado? y otra cosa que veo es que tenes 2 variables con el mismo nombre llamadas "registro" una es de tipo recordset y otra tipo string...cambiales el nombre porque puede haber conflicto..por mas que este declarada en general..es mejor diferenciar bien las cosas....

saludos.