Running stored procedures of a SQL server from c++ code [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a database in SQL server and have already created stored procedures which run on the data stored in this database. The client code of this databse is a native c++ windows service code. what I need is simple, connecting to the sql server from my c++ code, run the stored procedures ( sending the input parameters and getting the output) and closing the connection. How can I do this?
I found many solutions for connecting to db from c++ code but they are all based on some framework ( .Net, MFC, or some other managed c++ etc...) but my code is pure native legacy cpp code written in VS 2005 and for some compatibility reasons need to stay as it is.
I really appriciate any comments/ hints.

Use the SQL Server Native Client. This is a native library that provides OLE DB access to SQL Server. The client library itself is based on COM (as befits its object-oriented design):
This page provides a straightforward example of how to connect to a database server: https://msdn.microsoft.com/en-us/library/ms131323.aspx
And this page describes (though without giving an example) how to execute a command: https://msdn.microsoft.com/en-us/library/ms131427.aspx
A class and interface reference is provided here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms711625(v=vs.85).aspx

Related

How to compile C++ code for Roku? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have an android streaming client application which uses Java and cpp code. I want to port my application to Roku. I understand that Roku recommends only BrightScript for apps development.
1) According to this link (C/C++ development in Roku), gaming application can be written in cpp using marmalade and compiled for Roku.
2) But this link (How feasible is Roku app development with Marmalade?) clearly says marmalade can not be used for streaming application.
3) My questions are
(A) Is it possible to compile cpp for for roku?
(B) Where can I find the toolchain for building?
(C) If UI is developed using BrightScript, how can I call cpp functions from it?
You can't. Not independently from Roku Inc anyway - you will need a very close collaboration from them, which means you should be able to persuade their business development/partners department you are worth time and money. In other words, your company better be a household name.
You cannot "find" the C toolchain, it may only be bestowed to you by the Co on individual basis, after approval and under NDA.
If you don't have special relationship (project/contract) with Roku Inc, for non-games you can only develop in BrightScript. It's a mandate, not recommendation.
Specifically for your case, best option seems to be to use the already existing streaming formats/components the Roku API already provides. BrightScript is a script language, not fast enough to write a codec.
You have to use brightscript for Roku Streaming applications.

How to execute code written in an editor embedded within a browser [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Hi Guys I was writing a web application which requires me to compile and execute code from within a browser. I am a little clueless about it though I read the following links to see how I can go about it.
http://www.quora.com/Interviewstreet/How-can-I-build-a-compiler-like-the-one-on-InterviewStreet-from-scratch
http://norvig.com/lispy.html
developer.hackerearth.com
I am planning to write it for several languages namely C/C++/java/python/Ruby
Any pointers would be helpful
You can just take the code and send it to server server will compile and execute the code and send back to the browser.
If you don't have much time.
If you have much time then you can build your own compiler like one you want and integrate it with you'r web application. like w3school and ideone.
or pass it to local host compiler it will execute and return the result to the browser.

Saving data into file at free host [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have created an app (some kind of "client" app) that will have a "bug report" feature. The feature consists with pure text area from which the text should be sent and saved to a text file on the free host. Is it possible? If so, which c++ library could give me such ability?
EDIT:
In my intentions it had to be a simple application that a user has on his own computer. After finding some bug in my app there should be the "bug report" feature that will allow him to send the data (pure text) to some place that only I could reach. I was just thinking about free hosting (because it's... free), and save the data into a text file there. I'm sorry if my question wasn't appropriate.
If your free hosting permits it (and you should check that) you might code a CGI program, or a fastCGI application. There are several C++ libraries which might help, like libcgicc etc.
If you can afford a web server, there exist C++ libraries providing HTTP service, in particular Wt or (in C) Onion etc.
You could also consider other technologies, like OpaLang or Ocsigen (but I would not recommend PHP, even if it is a lot used).
MAybe your hosting enable ssh so you could use scp ....
And if your application is free software (e.g. GPL licensed), several free software hosting (freecode, sourceforge, github, gitorious ...) may offer also a bug database facility.

How can z/OS call a web service? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a COBOL program that needs to get data from a web service. Without using CICS what are my best options? I thought that a C program could read the web service and save it to a file, then the COBOL could read that file. Can COBOL call a web service? The data is about 300mb in size.
Use the IBM TCP/IP 'EZASOKET' modules
I work for a company with a z/OS system running mostly COBOL, batch (JCL) and CICS. To call webservices, we wrote a module to implement HTTP 1.0 using TCP/IP. With modules
EZASOKET
GETHOSTBYNAME
SOCKET
CONNECT
WRITE
FCNTL
READ
CLOSE
SELECTEX
supplementary modules:
EZACIC04 translates EBCDIC to ASCII
EZACIC05 translates ASCII to EBCDIC
EZACIC06 convert character to bit mask
EZACIC08 decode IP address
Since I wrote this for my company, I can't just give out the code. But for reference, it took me 3 days to write the module, and that was with an example to start with that did a partial hacky way of doing it.
You'll need to read through IBM's references to know how to use the EZA modules.
http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.halc001/sampcs.htm
It is possible to call java from COBOL programs on z/os.
We have done it in our company.
You have to specify that it is RECURSIVE
You have to import the classes
Class HelloJ is
"com.ibm.zos.batch.container.test.HelloJ"
Class JavaException is "java.lang.Exception"
Class BCDTranHelper is
"com.ibm.batch.spi.UserControlledTransactionHelper".
The you have to include JNI.
LINKAGE SECTION.
COPY JNI
***Then you can invoke java from COBOL in your PROCEDURE DIVISION with:
Invoke HelloJ "sayHello"
Also look at Java Exception Check * to see how to handle the exceptions.
This is very useful if you want to invoke a web service from your COBOL program on z/os.
see this link for more details.
http://pic.dhe.ibm.com/infocenter/zos/v1r13/index.jsp?topic=%2Fcom.ibm.zos.r13.iean500%2Fcodeexm.htm
Maybe have a look at this article. It suggests creating a C/C++ wrapper interace to the web service. Although this article is for iSeries, you might be able to implement something very similar under zSeries using BPXBATCH
Basically, they suggest using a C wrapper between your COBOL code and the C++ code that interfaces with the web service. This solution allows COBOL to call a C function in a relatively straight forward way. The C function mimics C++ behavior by implementing the call to the Web service using a C++ proxy.
If you can use Java at your site calling Java from a cobol program to access the web service may be an option. Assuming your using Enterprise cobol check out section 6.44 of Java Stand-alone Applications on z/OS Volume II
Use the z/OS client web enablement toolkit if you are at z/OS 2.1 or above.
Look at the sample in SYS1.SAMPLIB(HWTHXCB1) for Cobol.
If your Cobol is running under DB2 DSN command, you can also use SOAPHTTP* scalar functions.

How to write a good program for blocking unwanted / harmful websites [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I intend to write a simple application that will block network traffic (HTTP and HTTPS) with unwanted / malicious web sites.
Assumptions:
At the beginning the logic will be simple. After entering in the browser the address from the "black list" my logic should take control under communication and send defined by me site contents
Later I want to add some logic that will search web body looking for unwanted / harmful words
The program will be written in C++
I do not want to use existing libraries (open source etc.) only write all from scratch. J just want to learn windows network mechanism and layers
Unfortunately, I am a layman when it comes to play with the network layer in Windows.
Where do I start?
Where and how should I inject my filtering logic?
You should look into Windows Filtering Platform. This API gives you access to the network stack at a very low level.
You have at least 2 options:
Build your own proxy that filters traffic and replace unwanted content and setup this proxy in browser settings.
Create NDIS filter driver. You can start reading about NDIS here. You can also find sample driver in WDK.
I would prefer the first option.
I a working on something similar in my spare time(as if I had any).
It's not very easy.
It depends a lot on the OS version.
There's LSP(Layered Service Provider) but as I understand it it doesn't work on Win 7 or later. There is an implementation of something similar to what you are trying to achieve here.
For Win 7 and above there is the filter driver alternative but I tested it and if the site is using SSL you won't see anything. You have to somehow handle this either within the driver itself or redirect the traffic to a man-in-the-middle proxy. I didn't get that far yet.
Anyway this is M$'s official sample. And you might also be interested in this.