-
December 12th, 2013, 01:46 AM
#1
Databases in Visual Studio 2012
I have created a database in both Microsoft sql and in Visual Studio 2012 but I'm not sure how to connect to the database or run queries. I want this database to be local only, so it will always be on my system.
Does anyone have any links/tutorials I could view? Google is not being my friend.
-
December 12th, 2013, 02:04 AM
#2
Re: Databases in Visual Studio 2012
If you want a "personal database" on your computer you could consider Microsoft Access,
http://office.microsoft.com/en-us/access/
-
December 12th, 2013, 02:12 AM
#3
Re: Databases in Visual Studio 2012
I'm actually making a .dll for mIRC. I'd like to be able to store some information on a database and have the data available for view/manipulation during runetime.
I guess my question is, if I make a database in Visual Studio 2012 and create queries for this database, how do I connect to the database and execute the queries I have created?
-
December 12th, 2013, 05:14 AM
#4
Re: Databases in Visual Studio 2012
Are you going to store large amounts of data? If not, you should really look elsewhere. SQL server is a heavyweight "enterprise" product.
You could have a look at: SQLite and MongoDB
If the amount of data is really small, another option is to store it in the windows registry.
Nobody cares how it works as long as it works
-
December 12th, 2013, 06:21 AM
#5
Re: Databases in Visual Studio 2012
If the amount of data is really small, another option is to store it in the windows registry.
Have a look at using .ini files. See GetPrivateProfileString()/WritePrivateProfileString() or the other private profile functions.
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
Another possibility would be to use xml. There are various free XML c++ libraries available.
The choice really depends upon what you want to store and how much and how you want to access it.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
December 12th, 2013, 06:44 AM
#6
Re: Databases in Visual Studio 2012
Originally Posted by souly
I'm actually making a .dll for mIRC. I'd like to be able to store some information on a database and have the data available for view/manipulation during runetime.
I guess my question is, if I make a database in Visual Studio 2012 and create queries for this database, how do I connect to the database and execute the queries I have created?
Look at the CRecordset and CDatabase classes.
-
December 12th, 2013, 12:43 PM
#7
Re: Databases in Visual Studio 2012
Originally Posted by GCDEF
Look at the CRecordset and CDatabase classes.
Thanks I'll look into that and report back.
As to the others I appreciate the help but I could potentially be storing information for thousands of users. If you think this is still small enough to use in .ini let me know. I kind of figured using a ini file would be slow and really painful for retrieving data from users.
Edit:
Im storing data in columns like this: user(str), floodControl, banned(bit), link(bit), points(int), wins(int), loses(int)
this table will be accessed as long as a user is using the bot.
Last edited by souly; December 12th, 2013 at 12:47 PM.
-
December 12th, 2013, 01:07 PM
#8
Re: Databases in Visual Studio 2012
As to the others I appreciate the help but I could potentially be storing information for thousands of users. If you think this is still small enough to use in .ini let me know. I kind of figured using a ini file would be slow and really painful for retrieving data from users.
Yes, for that volume of data.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
December 12th, 2013, 03:34 PM
#9
Re: Databases in Visual Studio 2012
MS SQL Server Express Edition is a lightweight version of the well known "enterprise" product.
Though MySQL 5 looks same applicable for the task of this size, and same free as well.
SQLite is also fine for this, but not MongoDB which is non-SQL document oriented engine in contrast to true SQL engines above.
Best regards,
Igor
-
December 13th, 2013, 08:00 AM
#10
Re: Databases in Visual Studio 2012
it also depends if you need to do inserts/updates/deletes in the data.
if the data is static you have a lot more options available, including storing the data in const arrays in your code and compiling them into the exe.
If you do need insert/updates/delete, then ini/registry is usable for a few Kb of data (more is inapropriate/slow), xml is feasible up until a few Mb. anything beyond needs some form of database. I'd look at a lightweight embedded solution like SQLite first.
full databases are more complex to install, configure and set up, so this'll be an additional burden to your users, use it only if it really makes sense.
-
December 18th, 2013, 03:58 PM
#11
Re: Databases in Visual Studio 2012
Originally Posted by OReubens
it also depends if you need to do inserts/updates/deletes in the data.
if the data is static you have a lot more options available, including storing the data in const arrays in your code and compiling them into the exe.
If you do need insert/updates/delete, then ini/registry is usable for a few Kb of data (more is inapropriate/slow), xml is feasible up until a few Mb. anything beyond needs some form of database. I'd look at a lightweight embedded solution like SQLite first.
full databases are more complex to install, configure and set up, so this'll be an additional burden to your users, use it only if it really makes sense.
So I had some time to work on this and I was able to successfully compile using SQLite however the dll no longer loads into mIRC. Could adding an additional library to the dll cause it to fail? I tried including my dll and sqlite3 lib files and even the sqlite3.dll in the mIRC folder but still no luck. This is the first dll I have made so I'm new to the subject.
Also, if I create a database using my dll like so:
Code:
errHndlr = sqlite3_open_v2("test.db", &pDb, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
would the "test.db" be created at the location of my dll or at the location of the executable?
Last edited by souly; December 18th, 2013 at 04:01 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|