<%@ Language=VBScript %> <%
Dim con, cmd, rst
Set con = Server.CreateObject("ADODB.Connection")
Set cmd = Server.CreateObject("ADODB.Command")
Set rst = Server.CreateObject("ADODB.Recordset")
con.Open "Provider=SQLOLEDB.1;Initial Catalog=DATABASE_NAME;Data Source=SERVER_NAME;Workstation ID=SERVER_NAME;User Id=sa;PASSWORD=;"
Set cmd.ActiveConnection = con
Dim Msg, ID, hdnFor, Login, Password, Email
Dim MsgColor, LoginColor, PasswordColor, EmailColor
ID = Request ("hdnID")
hdnFor = Request ("hdnFor")
Login = Request ("txtLogin")
If Login = "" Then
Login = Null
End If
Password = Request ("txtPassword")
If Password = "" Then
Password = Null
End If
Email = Request ("txtEmail")
If Email = "" Then
Email = Null
End If
'*********************************************************
' VALIDATE PARAMETERS
'*********************************************************
Function ValidateParameters()
ValidateParameters = True
If IsNull(Login) Then
Msg = "Error! Required fields are missing!"
hdnFor = "Error"
MsgColor = "red"
ValidateParameters = False
LoginColor = "red"
End If
If IsNull(Password) Then
Msg = "Error! Required fields are missing!"
hdnFor = "Error"
MsgColor = "red"
ValidateParameters = False
PasswordColor = "red"
End If
End Function
'*********************************************************
' SAVE
'*********************************************************
If hdnFor = "Save" Then
If ValidateParameters() Then
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "spSaveUtilizatori"
If Len(ID) <> 0 Then
cmd("@ID") = ID
Else
cmd("@ID") = Null
End If
cmd("@Login") = Login
cmd("@Password") = Password
cmd("@Email") = Email
cmd.Execute
If cmd(0) = 0 Then
ID = cmd("@ID")
Msg = "Data Saved!"
MsgColor = "blue"
Else
Msg = "Error! " & cmd(0)
MsgColor = "red"
End If
End If
End If
'*********************************************************
' EDIT
'*********************************************************
If hdnFor = "Edit" Then
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "spEditUtilizatori"
cmd("@ID") = ID
Set rst = cmd.Execute
If Not rst.EOF Then
Login = rst("Login")
Password = rst("Password")
Email = rst("Email")
End If
If cmd(0) <> 0 Then
Msg = "Error! " & cmd(0)
MsgColor = "red"
End If
End If %>