Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
mysql> create procedure login(in user varchar(20),in pass varchar(20),out date1
date)
-> begin
-> set date1 = (select Dt from emp3 where userid=user and password = pass);
-> end$$
Query OK, 0 rows affected (0.00 sec)



VB
Dim con As MySqlConnection = New MySqlConnection("Server=localhost;Database=siddhu;Uid=root;Password=1234;")
      Dim message As String = [String].Empty
      Dim cmd As MySqlCommand = New MySqlCommand("login", con)
      con.Open()
      cmd.CommandType = CommandType.StoredProcedure
      cmd.Parameters.Add(New MySqlParameter("user", MySqlDbType.VarChar))
      cmd.Parameters("user").Direction = ParameterDirection.Input
      cmd.Parameters("user").Value = "prasad"

      cmd.Parameters.Add(New MySqlParameter("pass", MySqlDbType.VarChar))
      cmd.Parameters("pass").Direction = ParameterDirection.Input
      cmd.Parameters("pass").Value = "530"

      cmd.Parameters.Add(New MySqlParameter("@date1", MySqlDbType.Date))
      cmd.Parameters("@date1").Direction = ParameterDirection.Output
      Try

      Dim i As Integer
      i = cmd.ExecuteNonQuery()
      If i > 0 Then
          MessageBox.Show(cmd.Parameters("@date1").Value)
      Else
          MessageBox.Show(i)
      End If
      Catch ex As Exception
          MessageBox.Show(ex.ToString())
      End Try

      con.Close()

always it give me output as zero
Posted

I am not sure that executenonquery will return 1, I suggest you check the value of date1 either way and see what it is.
 
Share this answer
 
Comments
kalisiddayya 2-Jan-13 23:47pm    
thank u frd
to receive out put you have to write a line that will receive output see underlined portion of below code...
VB
cmd.Parameters.Add(New MySqlParameter("@date1", MySqlDbType.Date))
cmd.Parameters("@date1").Direction = ParameterDirection.Output
'execute then...
dim outputdate = cmd.parameters(0).Value 'Index of your Output parameter date1


if you are inserting/updating/deleting record then use<br />
cmd.ExecuteNonQuery()<br />
<br />
if just selecting then<br />
cmd.ExecuteQuery()


Happy Coding!
:)
 
Share this answer
 
Comments
kalisiddayya 2-Jan-13 23:48pm    
thank u frd
Aarti Meswania 2-Jan-13 23:50pm    
Welcome! :)
Glad to help you! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900