searchsanjaysharma
asked on
How to call a procedure in Java.
How to call a procedure in java/
How to test whether a connection is open or closed.
How to test whether a connection is open or closed.
ASKER
I am sending the example in dot net.
I want to check whether the connection is closed, if so then only open it.
Secondly how to call a procedure.
I want to check whether the connection is closed, if so then only open it.
Secondly how to call a procedure.
ASKER
Try
con = New SqlConnection("Data Source=192.168.171.41;Init ial Catalog=amis;User Id=sa;Password=XXXX")
cmd = New SqlCommand
cmd.CommandType = CommandType.StoredProcedur e
cmd.Connection = con
cmd.CommandText = "saveuser"
If con.State = ConnectionState.Open Then con.Close()
con.Open()
cmd.Parameters.AddWithValu e("@userna me", txtusername.Text.Trim())
cmd.Parameters.AddWithValu e("@passwo rd", txtpassword.Text.Trim())
cmd.ExecuteNonQuery()
MessageBox.Show("Record Saved Sucessfully")
Catch eee As Exception
MessageBox.Show("Error occured" & eee.ToString())
Finally
con.Close()
End Try
con = New SqlConnection("Data Source=192.168.171.41;Init
cmd = New SqlCommand
cmd.CommandType = CommandType.StoredProcedur
cmd.Connection = con
cmd.CommandText = "saveuser"
If con.State = ConnectionState.Open Then con.Close()
con.Open()
cmd.Parameters.AddWithValu
cmd.Parameters.AddWithValu
cmd.ExecuteNonQuery()
MessageBox.Show("Record Saved Sucessfully")
Catch eee As Exception
MessageBox.Show("Error occured" & eee.ToString())
Finally
con.Close()
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tx
- What type of connection are you attempting to test to see if it's open or closed.
- Are you trying to do this with a Java applet, or with JavaScript in an HTML page?