0

How do you get a vb.net program to send a session kill command to Oracle? I can do it in sqlplusw by just typing:

alter system kill session '45,30665';

In vb.net, I'm trying to do this with an oracle.dataAccess object:

oraConn As New OracleConnection("Data Source=db1;User ID=usr;Password=pw")
oraConn.Open()

Dim cmd As New OracleCommand
cmd.Connection = oraConn
cmd.CommandType = CommandType.Text
cmd.CommandText = "alter system kill session '45,30665';"
cmd.ExecuteNonQuery()
cmd.Dispose()

When it gets to the ExecuteNonQuery line, it throws an exception "ORA-00911: invalid character". I think it's expecting an SQL statement. I'm using VB Express 2008.

Justin Cave
  • 227,342
  • 24
  • 367
  • 384
ls1m
  • 1
  • The ORA-00911 error is being thrown because you don't want a semicolon in your statement. There may be other errors as well. – Justin Cave May 23 '14 at 19:17
  • I'll be durned. I can't believe it was that simple. Removed the semicolon and it works now. thanks! – ls1m May 23 '14 at 19:21

1 Answers1

1

You don't want semicolons in statements that you're sending from a client. Get rid of the semicolon at the end of the alter system

cmd.CommandText = "alter system kill session '45,30665'"
Justin Cave
  • 227,342
  • 24
  • 367
  • 384