472,352 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

Need some help with Visual Basic and Oracle

Hello all!

I develop application in Visual Basic .NET and ORACLE database.
My question is how do I "send" script file to the database using visual
basic .net.
Other words, is there any way to send to the database a script file to run,
as done by: "@FullPath\FileName" in SQL PLUS ?
If not, then I need your help with something else: I tried to send to the
database the script file's content, in order to run the commands in it
(create table) in my case, but I got an error message: "ORA-00911: Invalid
character".
In order to run the script file content, I read it into a string variable
called sqlQuery and than use command to run it:

Dim command As New OracleCommand(sqlQuery, connection)
command.ExecuteNonQuery()

At this point I get the error message. I thoght it might related to syntax
or so, but when I copy and paste the same code (the script file content) in
SQL PLUS it creates the table without problem.
Last, here is the file content I need to run by visual basic:

//////////////////////////////////////// Begin of examle
////////////////////////////////////////////////////////////
PURGE TABLESPACE USERS USER SCOTT;

CREATE TABLE inventory
(
item_num number (9) REFERENCES items ( item_num ) ON DELETE CASCADE ,
stock_num number (9) REFERENCES stocks ( stock_num ),
from_month number (2) CHECK ( from_month <= 12 AND from_month >= 1 ),
quantity number (9,2) ,
PRIMARY KEY( item_num , stock_num )
);

//////////////////////////////////////// End of examle
////////////////////////////////////////////////////////////

Thanks!
Tom.
Oct 18 '05 #1
1 2047
Tom, I believe it to be the multiple statements. Just in way to diagnose
problem, separate both of the statements and so that you just have the Purge
statement and then the create table statement. At such point, try to run
each and see if they run. I know in Sql Server there is for instance a GO
statement which is perfectly valid in Query analyzer but when used in a
string, it creates exceptions.

As far as Sql Plus - you can use the command shell to start it but at last
glimpse at least with version 9, I don't think you can execute statement.
If you pass file name as parameter, it will open it up and load file, but I
can't think of if it can run script. Perhaps send keys woudl do it but this
is very not elegant and doubtful what you seek. I will see though if I
can - but in meantime see if it is possible for you to split all statements
and see if it were to still run.
"Tom Rahav" <to******@nospam.nospam> wrote in message
news:eF*************@TK2MSFTNGP10.phx.gbl...
Hello all!

I develop application in Visual Basic .NET and ORACLE database.
My question is how do I "send" script file to the database using visual
basic .net.
Other words, is there any way to send to the database a script file to run, as done by: "@FullPath\FileName" in SQL PLUS ?
If not, then I need your help with something else: I tried to send to the
database the script file's content, in order to run the commands in it
(create table) in my case, but I got an error message: "ORA-00911: Invalid
character".
In order to run the script file content, I read it into a string variable
called sqlQuery and than use command to run it:

Dim command As New OracleCommand(sqlQuery, connection)
command.ExecuteNonQuery()

At this point I get the error message. I thoght it might related to syntax
or so, but when I copy and paste the same code (the script file content) in SQL PLUS it creates the table without problem.
Last, here is the file content I need to run by visual basic:

//////////////////////////////////////// Begin of examle
////////////////////////////////////////////////////////////
PURGE TABLESPACE USERS USER SCOTT;

CREATE TABLE inventory
(
item_num number (9) REFERENCES items ( item_num ) ON DELETE CASCADE ,
stock_num number (9) REFERENCES stocks ( stock_num ),
from_month number (2) CHECK ( from_month <= 12 AND from_month >= 1 ),
quantity number (9,2) ,
PRIMARY KEY( item_num , stock_num )
);

//////////////////////////////////////// End of examle
////////////////////////////////////////////////////////////

Thanks!
Tom.

Oct 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ian DeRock | last post by:
I'm fairly new to XML. As I can see it, XML is a way to organize data like in a table in a RDB, or the RDB itself. I have used XML in application...
29
by: RAY | last post by:
Hi , my boss has asked I sit in on an interview this afternoon and that I create some interview questions on the person's experience. What is...
1
by: tristant | last post by:
Hi All, We want to develope Windows and Web .NET application on Oracle 9i on AIX. Also we will use Crystal Report for reporting. I have question...
1
by: Tom Rahav | last post by:
Hello all! I develop application in Visual Basic .NET and ORACLE database. My question is how do I "send" script file to the database using...
9
by: D. Patrick | last post by:
I need to connect to an Oracle database. I've never done it before. I see that with framework 1.1 you had to download ODP.NET from Oracle's site...
1
by: kiran261 | last post by:
visual basic and oracle connectivity i want to know how can i access records from oracle in visual basic what is the diffrence between connect &...
0
by: keshabtsk | last post by:
I have a problem that to create an application which demands to transfer tthe data from Visual Fox Pro 6 to Oracle 8i. Oracle 8i is hosted on Windows...
1
by: subratamaji | last post by:
Hi, I am new to crystal report. Can any one plz guide how to use crystal report 11.5 with visual basic 6.0. Is it already included in visual...
1
by: Mike001 | last post by:
my question is that for version control for oracle database at object level i.e. at table etc, oracle 10g SCM will be more feasible soultion or...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.