Hi All,
I've been trying to look for a way to run a set of DDL statements. I normally have text files with DDL Statements on it. So what I do is load the contents of this text file into a Textbox and then set the Textbox.Text as the CommandText of my command object. Unfortunately I get errors.
Here's my code...
The errors that I get areCode:Private Sub btnLoadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim OpenDiag As New OpenFileDialog Dim txtReader As StreamReader OpenDiag.ShowDialog() If OpenDiag.FileName <> "" Then txtReader = File.OpenText(OpenDiag.FileName) CommandTextBox.Text = txtReader.ReadToEnd End If End Sub Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim myConn As New OracleConnection(My.Settings.ConnectionString) Dim myComm As New OracleCommand(CommandTextBox.Text, myConn) Try myConn.Open() myComm.ExecuteNonQuery() myConn.Close() Catch ex As OracleException MessageBox.Show(ex.Code & ": " & ex.Message) End Try End Sub
"ORA-00900: Invalid SQL Statement"
- Not sure how I get this but I noticed that if i had remarks/comments in my text file, this is the error that i get. Although i don't get this error if i execute in SQL Plus.
"ORA-00911: Invalid Character"
- after removing the remarks/comments, i get this error. i tried removing the semi-colon ";" then it works okay if i'm running 1 DDL statement in my file.. but if i my file contains to DDL statements for example, then i get the this error "ORA-00922: Missing or Invalid Options".
can anyone help me with this?
thanks.




Reply With Quote