Call a DB Function in VB.NET
Need Help Programming With Databases (VB.NET)
Hello...
I find all of you here very helpful... Could someoen please help me out...
I need an immediate help?.I am working on a project using PDA. I have installed Oracle Lite. I wana call a database function. My code is as follows:
Dim cmd1 As LiteCommand = con.CreateCommand()
Cmd1.CommandText = "fncEncryptPsswd"
Cmd1.CommandType = CommandType.StoredProcedure
Dim p1 As New OracleParameter("p_input1", DbType.String)
P1.Value = UCase(Trim(txtPsword.Text))
P1.Direction = ParameterDirection.Input
Cmd1.Parameters.Add(p1)
Dim p2 As New OracleParameter("output1", DbType.String)
P2.Direction = ParameterDirection.ReturnValue
Cmd1.Parameters.Add(p2)
Cmd1.ExecuteNonQuery()
Con.Close()
It throws the follwoing error at cmd1.ExecuteNonQuery():
37000[POL- 5228] syntax error
I am not sure what to do
As an alternative I tried to convert the same function into .Net...
Original in SQL is:
FUNCTION Fncencryptpsswd(p_input1 IN VARCHAR2) RETURN VARCHAR2 IS
X NUMBER := 31;
S NUMBER := 1;
R1 NUMBER := 29;
R2 NUMBER := 31;
R3 NUMBER := 93;
Ps NUMBER := 0;
Output1 VARCHAR2(100) := NULL;
BEGIN
FOR s IN 1..LENGTH(p_input1) LOOP
X := MOD((((x+TO_NUMBER(ASCII(SUBSTR(p_input1,s,1)))+ ps)*r1)+r2),r3);
Output1 := output1||CHR(x+33);
Ps := x;
END LOOP;
Output1 := REPLACE(output1,'"','0');
Output1 := REPLACE(output1,'@','a');
RETURN output1;
END Fncencryptpsswd;
Now the one I have written in .Net is (not sure how to write it better):
For s = 1 To pass.Length
X = (((x + (Asc(pass.Substring(s, 1))) + ps) * r1) + r2)
Y = x Mod r3
Output = output & Chr(y + 33)
Ps = y
Next s
Output = Replace(output, " ", "", "0")
Output = Replace(output, "@", "a")
The output is totally different from EACH OTHER...If my password is TEST...In sql, (ASCII(SUBSTR(p_input1,s,1))) gives '84' and (Asc(pass.Substring(s, 1))) gives me '69'...Where am I going wrong...
If I pass test I must get "3(W4" as the output from both functions...
Someone Please help me with this...
-reply by Rinjin
Reply