Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
| Search | Today's Posts | Mark Forums Read
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2009, 05:36 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default Oracle Error When Issuing Command

I have:
Code:
Dim cn As OracleConnection = Nothing
    cn.ConnectionString = "Data Source = DIS;" & _
                          "User ID     = xhyt;" & _
                          "Password    = xhyt"
    cn.Open   ' cn.State = Open {1} after this.
 
Dim cmd As New OracleCommand()
    cmd.Connection  = cn
    cmd.CommandType = CommandType.Text
 
Try
    .CommandText = "ALTER USER PT109 IDENTIFFIED BY the1user"
    .ExecuteNonQuery
Catch ex As OracleException
   ' ex.Message = "ORA-00922: missing or invalid option"
End Try
What option might be invalid or missing?

What will I run into when I try "ALTER USER PT109 ACCOUNT UNLOCK"?
.
 
Old March 24th, 2009, 08:09 PM
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

I'm confused. You are initialising cn to Nothing then setting the ConnectionString property - this should throw a NullReferenceException on line 2. Then you are using .CommandText without wrapping it in a With statement - syntax error.

That aside, the error is to do with the actual Oracle statement. All I can see wrong with it is that you have spelt IDENTIFIED wrong. The only other time I am aware of this error occuring for this statement is if you use invalid characters for the password, which is not the case here.

See http://www.petefinnigan.com/weblog/a...s/00000021.htm for some examples and explanation

HTH
Phil
The Following User Says Thank You to philip_cole For This Useful Post:
BrianWren (March 25th, 2009)
 
Old March 25th, 2009, 11:55 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

DOH!

In reality, what I am doing is
Code:
    Dim cn As OracleConnection = Nothing
   If OpenConnection(cn) Then Exit Sub   ' Fn raises error, if nec.
...
...
Private Function OpenConnection(ByRef cn As OracleConnection) As Boolean
   cn = new OracleConnection()
 
   cn.ConnectionString = "Data Source = wigga ;" & _
                         "User ID = " & frmLogin.txtUsrNm.Text & ";" & _
                         "Password = " & frmLogin.txtPW.text
   try
       cn.Open
   Catch ex As OracleClient.OracleException
       MsgBox(ex.Message & " ...", , "Error")
       If cn.State <> ConnectionState.Closed Then cn.Close
       Return True
   Catch ex As Exception
       MsgBox(ex.Message & " ... ", , "Error")
       If cn.State <> ConnectionState.Closed Then cn.Close
       Return True
   End Try
 
   Return False
 
End Function
Just thought to post fewer details.

But you are so right about the spelling... I'll try fixing that, and see what benefits derive...
 
Old March 25th, 2009, 12:07 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Works much better when IDENTIFIED is spelled that way, rather than IDENTDDYSHNBCDFFHIED...

Thanks Phil.
 
Old March 26th, 2009, 11:10 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Proper spelling fixed it—thanks Phil.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell command execution error toshesh VB Databases Basics 3 January 7th, 2006 03:17 AM
Error in issuing Parameterized Command yoord ADO.NET 1 June 15th, 2004 06:22 PM
Help! 'Command object error' sisi Classic ASP Databases 4 May 25th, 2004 06:23 PM
'bad command or file name' error freddie2165 JSP Basics 6 April 16th, 2004 06:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.