Running oracle commands script file inside C# - c#

I have an application which has an oracle database, so the installation of the application needs running some oracle commands script files to create the database and perform some DDL operations.
I was trying to prepare an installation wizard using C# forms application. This wizard needs to run these commands. My questions are: Is C# windows forms app a good choice to achieve that? And how to perform it? i.e. how to run oracle commands script files from inside the application? I exactly need a function that takes the file path as input parameter and executes the commands within the script files...
Thanks in advance

Related

How to call C# app / .exe from SSMS script to run locally, not on server?

I want to plot various columns from my DBs.
There does not appear to be a simple way to do this from SQL Server Management Studio (SSMS), so I have created a small C# app that takes a table name and column name and does the plotting.
I would like to call this from SSMS, within the .sql file, with something like:
EXEC "C:\\MyPlotApp.exe [dbo].[Table] ColA"
I found xp_cmdshell BUT this appears to execute on the server, I want to execute locally.
I can create an External Tool pointing to my App.exe (even though this cannot be executed directly from the SQL script). As a parameters I list $(CurText) which passes in my string. Only problem is that there is no parameter options to pass in table name and cursor column position from Results window.
SSMS supports SQLCMD mode (Query-->SQLCMD Mode). This allows you to use SQLCMD commands within the SSMS query window, including the !:: command to launch an external program on the client synchronously. For example:
:!! C:\MyPlotApp.exe "[dbo].[Table]" "ColA"
There is no simple way to pass in Results tab values to external tools, as far as I can tell. There are only three options that I can think of at the moment:
Set up your external tool C# app to read from the clip board. Then, in the "Results Grid", select the column and hit Control-C (this will copy all values to the clipboard). Then, launch your external app which will read that list of values from the clip board and plot them. Not sure how many rows you are working with, but it might be an issue if hundreds of thousands / millions. I guess it depends on how much available RAM your workstation has.
Technically, you don't really need SSMS to execute the query just so that you can pass the results to another app. Your C# app can execute the query and read the result rows directly.
If you want actual access to the "Results" Grid values, then you need to write your own SSMS extension. Do a search on creating your own extension as there are few tutorials out there.

Running the ADO.net program at regular interval

I have a sql serevr database in a remote system .I am using ADO.net to bring that database table values into my local mysql server .
Now i want to fetch data from remote db into my local db every 15 min .I think this will involve running the program every 15 min.Please suggest if there is any better way .I want to make it automatic.
I tried with putting the package.dtsx in schedule task . It doesnt work .I think we can make an exe file and then run it
Can you tell me how do i make an exe file?
How do i do this.
Thanks
Since you've tagged your question with Visual Studio 2008, I'll assume you have that.
Create a new project of type Console Application. If you add your code to that project and compile it, the result will be a .exe file which you can run as a Scheduled task.
However, since you are talking about a .dtsx package, another option would be to add your .dtsx package as a scheduled job in the server you are trying to import data to.
Read this on how you schedule a job in SQL Server.

How to write a Config App for a Console App - sharing data?

My console app uses a bunch of string variables entered by the user. Currently the user can type these as parameters to the console app which then persists them using Properties.Settings.
Instead I'd like a GUI app which has a bunch of text boxes and a 'Save' button.
How can I make this work? I presume there needs to be a way for each app to read/save the common variables. It should work without needing admin privileges when installed on customer's machines.
.NET supports XML (De)Serialization.
Define a class with your setting parameters as fields, connect those fields to your GUI elements, the way you want. Write that class to the XML file and restore the values on application launch.

How to convert/export SQL Server database to MSAccess from c#

I have a SQL Server database, i need to export all of the data into an Access mdb that users can download. What's the simplest way of doing this from C#?
I realise I could have a blank (but with schema in place) mdb, and when i want to export I could copy it, then read all the data from SQL Server into the mdb via datasets, but that seems like a right faff. Is there an easier way?
Thanks
Could you create a DTS Package to do the export, then write a C# app to execute the DTS package, the user then just needs to execute your C# app? You could also set the DTS package to run automatically if you don't want user interaction.

Run.Cs or.Vb files without calling the in asp.net

By security reason I ask this... Can .cs or .vb files to run in any way without calling those in asp.net?
C# and VB script requires a host to interpret the code. Windows Explorer wont interpret C# or VB script. However, there are applications which can be launched which will interpret the script. For example, cscript.exe can interpret *.vbs files and execute the code within it.
There are also other more malevolent techniques to trick applications into executing script. This is particularly used in getting Microsoft office to open exploits on computers via scripting.
they can be compiled using csc.exe or vbc.exe and then run as .exe, but this can be done only if malevolent user has logged in at your server.
And if so he can do mostly anything his windows account permits.

Categories