Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C Windows Linux
Hi,
Well i thought of figuring out a way to write a Client program in C which takes an sql query as the user input and then fetches back the result to the screen.
Now if the database is on a remote machine, can i do the same thing through sockets to execute the query on the remote server and get back the results on the client screen.
Any programmatic examples on this that you could help me with.
Any sample example you could please provide me or any particular article which explicitly describes this scenario.
 
Thank you.
Posted 9-Jan-12 6:32am
Comments
Richard MacCutchan at 9-Jan-12 15:07pm
   
In theory you could do this but it may be that the SQL response is in some sort of encoded format that you would need to disassemble. I think this may be a question for Google.
SAKryukov at 9-Jan-12 20:14pm
   
Only in theory. It's not clear why doing all that.
--SA
Richard MacCutchan at 10-Jan-12 3:26am
   
I agree it seems totally pointless, but OP did ask the question.
kiranbhatter at 10-Jan-12 10:03am
   
i am trying to create a GUI tool in C which serves as a tool to access database in a GUI fashion. :)
Albert Holguin at 10-Jan-12 13:37pm
   
This isn't that difficult but it requires you to know a broad range of stuff... know how to make SQL queries, how to communicate over sockets, and know what the authentication process and application layer the server has set-up. Like I said, not that hard, but if you're just starting out, it's a handful.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can get better help if you let us know what database you are using. Because most of the databases(all the databases I have already learned provide this, I don't know about those database which i didn't learn) provide API to connect with Database Server. So do the following:
1. Search on google for the instruction to connect with your database.
2. If you can find but still having problem then let us know.
3. If you cannot find the server based solution for your client then please communicate with your database provider.
4.If they dont provide at all, then you might need to create the socket based client. In that case, you would also have to learn about how to develop socket based client server application
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You do not need sockets to do this. Database libraries have their own client interfaces that do the task for you. There are few abstraction layer that can be used if you are using different type of databases.
Well you can use any of the below libraries:
1. SOCI - Database Abstraction Library[^]
2. POCO Library Database abstraction layer[^]
These provide abstraction for dealing with different databases in a unified way from C++. I have used SOCI and it work great.
I have a windows build for SOCI using visual studio 2008 in the following location for my use. You can use it if you wish. It uses sqlite3 as database.
My SOCI 3.1 Build for Visual Studio 2008.[^]
Let me know if you need any help.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 505
1 Maciej Los 325
2 Richard MacCutchan 265
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 10 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100