Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › How to put Database in program (Not Access)
New Posts  All Forums:Forum Nav:

How to put Database in program (Not Access)

post #1 of 12
Thread Starter 
In my programming classes all we use is VB, and we have worked many times with using databases in our programs to store the information.

BUT

We have only ever created Access databases and put them into a folder in solution folder.

My problem is that I wish to make a very simplistic program for a friend and I would need to store information, and he does not have Microsoft access, so the program wouldn't work. So how do other programs store their data and stuff without having the user install a second piece of software?
OC Beast
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8500 @4GHZ Gigabyte P45 4850x2 2GB IT LIVES! 4GB 
Hard DriveOptical DriveOSMonitor
500AAKS+250external CD-DVD combo windows 7 ultimate x64 26" 
KeyboardPowerCaseMouse
MC$ wireless 650w corsair antec 900 Logitech battlefield 2142 G5 
  hide details  
Reply
OC Beast
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8500 @4GHZ Gigabyte P45 4850x2 2GB IT LIVES! 4GB 
Hard DriveOptical DriveOSMonitor
500AAKS+250external CD-DVD combo windows 7 ultimate x64 26" 
KeyboardPowerCaseMouse
MC$ wireless 650w corsair antec 900 Logitech battlefield 2142 G5 
  hide details  
Reply
post #2 of 12
They use embedded SQL. Access is a real crappy DB solution, I don't know why they even consider that in programming

ALSO If you're developing a large-scale system, SQL Express or the full SQL would be way better,
OR
If you're making a small program and don't want to bother learning SQL, you can use serialization on a collection class, like List<>

You can simulate DB by using List<List<>> too


Edited by ronnin426850 - 1/9/11 at 3:05am
My Rig
(14 items)
 
Ex-wife's Rig
(15 items)
 
 
CPUMotherboardGraphicsRAM
Core i5 4460 AsRock H81M-DG4 Sapphire Rx470 Platinum KVR 1600 16Gb 
Hard DriveHard DriveCoolingOS
2x Seagate 3Tb Samsung 850 EVO 120 Scythe Ninja 3 Rev.B Windows 10 Pro 
MonitorKeyboardPowerCase
Fujitsu Siemens A17-2A Logitech K280e SuperFlower SF-550K12XP Thermaltake Versa H25 
MouseAudio
Logitech G402 Sony MDR XD150 
CPUMotherboardGraphicsRAM
Athlon 750K 4.0Ghz AsRock FM2A75 Pro4+ Sapphire R9 270X Dual-X Kingston 2x4Gb 1600 
Hard DriveHard DriveOptical DriveCooling
Samsung 850 EVO 120  Western Digital 320Gb LiteON DVD-RW CoolerMaster Hyper Z600 
OSMonitorKeyboardPower
Windows 7 Pro x64 Toshiba 32" FullHD TV Logitech FSP Hexa 550 
CaseMouse
DeLUX Logitech 
  hide details  
Reply
My Rig
(14 items)
 
Ex-wife's Rig
(15 items)
 
 
CPUMotherboardGraphicsRAM
Core i5 4460 AsRock H81M-DG4 Sapphire Rx470 Platinum KVR 1600 16Gb 
Hard DriveHard DriveCoolingOS
2x Seagate 3Tb Samsung 850 EVO 120 Scythe Ninja 3 Rev.B Windows 10 Pro 
MonitorKeyboardPowerCase
Fujitsu Siemens A17-2A Logitech K280e SuperFlower SF-550K12XP Thermaltake Versa H25 
MouseAudio
Logitech G402 Sony MDR XD150 
CPUMotherboardGraphicsRAM
Athlon 750K 4.0Ghz AsRock FM2A75 Pro4+ Sapphire R9 270X Dual-X Kingston 2x4Gb 1600 
Hard DriveHard DriveOptical DriveCooling
Samsung 850 EVO 120  Western Digital 320Gb LiteON DVD-RW CoolerMaster Hyper Z600 
OSMonitorKeyboardPower
Windows 7 Pro x64 Toshiba 32" FullHD TV Logitech FSP Hexa 550 
CaseMouse
DeLUX Logitech 
  hide details  
Reply
post #3 of 12
use Read/Write in VB ?

write to a text file, its really ezy

Quote:
"oWrite.WriteLine(“Write a line to the fileâ€)" ???


Read


Dim EntireFile as String

oRead = oFile.OpenText(“C:\\xdragoon.txtâ€)

EntireFile = oRead.ReadToEnd()


Quote:

Dim FILE_NAME As String = "C:\\Users\\Owner\\Documents\est2.txt"

If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write(TextBox1.Text)
objWriter.Close()
MsgBox("Text written to file")
Else
MsgBox("File Does Not Exist")
End If

hope that helps : )
xdragoon
(14 items)
 
  
Reply
xdragoon
(14 items)
 
  
Reply
post #4 of 12
There are a few ways to go about this depending on what kind of information you're storing and where you want to store it, as well as how you are planning on reading it.

If you're planning on storing information in a VB program, you can do as xdragoon suggested and write the information to a text file stored on the local computer.
Below is how you would write to a text file:
Quote:
Dim vFileName = "C:\emp\\TestFile.txt"
Dim rvSW As New IO.StreamWriter(vFileName , FALSE )
Dim vText As String = "Hello World"
rvSW.WriteLine(vText)
rvSW.Close
Option number two is much more tricky and you shouldn't bother with it if you're planning on using VB. People who need to store large volumes of information create databases, and the most effective way to do this is through SQL. If you wish to learn to learn the SQL language, have a look at this tutorial.

I hope I've helped
Orange != Red
(20 items)
 
  
Reply
Orange != Red
(20 items)
 
  
Reply
post #5 of 12
Thread Starter 
I've used plain text files before, but this is going to have a bit of data in it.

I would like to use a database especially since I am going to hopefully upload it to a database on a web server.

For embedded SQL you would have to buy/install something, because isnt SQL just the language (structure query language?) its not an actual database right, just the language used to talk to the database?
OC Beast
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8500 @4GHZ Gigabyte P45 4850x2 2GB IT LIVES! 4GB 
Hard DriveOptical DriveOSMonitor
500AAKS+250external CD-DVD combo windows 7 ultimate x64 26" 
KeyboardPowerCaseMouse
MC$ wireless 650w corsair antec 900 Logitech battlefield 2142 G5 
  hide details  
Reply
OC Beast
(13 items)
 
  
CPUMotherboardGraphicsRAM
E8500 @4GHZ Gigabyte P45 4850x2 2GB IT LIVES! 4GB 
Hard DriveOptical DriveOSMonitor
500AAKS+250external CD-DVD combo windows 7 ultimate x64 26" 
KeyboardPowerCaseMouse
MC$ wireless 650w corsair antec 900 Logitech battlefield 2142 G5 
  hide details  
Reply
post #6 of 12
Quote:
Originally Posted by ZTR1760 View Post
I've used plain text files before, but this is going to have a bit of data in it.

I would like to use a database especially since I am going to hopefully upload it to a database on a web server.

For embedded SQL you would have to buy/install something, because isnt SQL just the language (structure query language?) its not an actual database right, just the language used to talk to the database?
Microsoft SQL / SQL Express and MySQL, as well as dozen of others, are exactly that, DB engines, fully functional SQL Express is free, but requires instalation on the client side
My Rig
(14 items)
 
Ex-wife's Rig
(15 items)
 
 
CPUMotherboardGraphicsRAM
Core i5 4460 AsRock H81M-DG4 Sapphire Rx470 Platinum KVR 1600 16Gb 
Hard DriveHard DriveCoolingOS
2x Seagate 3Tb Samsung 850 EVO 120 Scythe Ninja 3 Rev.B Windows 10 Pro 
MonitorKeyboardPowerCase
Fujitsu Siemens A17-2A Logitech K280e SuperFlower SF-550K12XP Thermaltake Versa H25 
MouseAudio
Logitech G402 Sony MDR XD150 
CPUMotherboardGraphicsRAM
Athlon 750K 4.0Ghz AsRock FM2A75 Pro4+ Sapphire R9 270X Dual-X Kingston 2x4Gb 1600 
Hard DriveHard DriveOptical DriveCooling
Samsung 850 EVO 120  Western Digital 320Gb LiteON DVD-RW CoolerMaster Hyper Z600 
OSMonitorKeyboardPower
Windows 7 Pro x64 Toshiba 32" FullHD TV Logitech FSP Hexa 550 
CaseMouse
DeLUX Logitech 
  hide details  
Reply
My Rig
(14 items)
 
Ex-wife's Rig
(15 items)
 
 
CPUMotherboardGraphicsRAM
Core i5 4460 AsRock H81M-DG4 Sapphire Rx470 Platinum KVR 1600 16Gb 
Hard DriveHard DriveCoolingOS
2x Seagate 3Tb Samsung 850 EVO 120 Scythe Ninja 3 Rev.B Windows 10 Pro 
MonitorKeyboardPowerCase
Fujitsu Siemens A17-2A Logitech K280e SuperFlower SF-550K12XP Thermaltake Versa H25 
MouseAudio
Logitech G402 Sony MDR XD150 
CPUMotherboardGraphicsRAM
Athlon 750K 4.0Ghz AsRock FM2A75 Pro4+ Sapphire R9 270X Dual-X Kingston 2x4Gb 1600 
Hard DriveHard DriveOptical DriveCooling
Samsung 850 EVO 120  Western Digital 320Gb LiteON DVD-RW CoolerMaster Hyper Z600 
OSMonitorKeyboardPower
Windows 7 Pro x64 Toshiba 32" FullHD TV Logitech FSP Hexa 550 
CaseMouse
DeLUX Logitech 
  hide details  
Reply
post #7 of 12
MYSQL would be good to use. It is easy to use as well.
There are only 3 commands you would normally need to use:
Code:
INSERT INTO (table here) VALUES (1, 2, 3, etc)
SELECT (variable or wildcard) FROM (table here)
DROP (table or database name)
I also made a php interpreter for .net as some mysql hosts dont allow the way the mysql connector for .net connects.
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #8 of 12
Instead of VB, consider using Python + sqlite (an embedded database engine). Python comes with a sqlite module that is very easy to use, and its syntax is very similar to MySQL.
SG06
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570S 65W ASRock Z77E-ITX VisionTek AMD Radeon RX 480 8GB Reference G.SKILL Sniper DDR3-2400 (@ 1866 9-10-10-28) 2x8GB 
Hard DriveHard DriveCoolingCooling
Crucial m4 256GB Toshiba P300 3TB Prolimatech Samuel 17 Noctua NF-F12 
OSMonitorMonitorKeyboard
Windows 10 Pro x64 HP Omen 32" HP Pavilion 27xi Das Model S Professional Silent 
PowerCaseMouseAudio
Silverstone SST-ST45SF Silverstone SG06 Microsoft Intellimouse Realtek ALC898 
  hide details  
Reply
SG06
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570S 65W ASRock Z77E-ITX VisionTek AMD Radeon RX 480 8GB Reference G.SKILL Sniper DDR3-2400 (@ 1866 9-10-10-28) 2x8GB 
Hard DriveHard DriveCoolingCooling
Crucial m4 256GB Toshiba P300 3TB Prolimatech Samuel 17 Noctua NF-F12 
OSMonitorMonitorKeyboard
Windows 10 Pro x64 HP Omen 32" HP Pavilion 27xi Das Model S Professional Silent 
PowerCaseMouseAudio
Silverstone SST-ST45SF Silverstone SG06 Microsoft Intellimouse Realtek ALC898 
  hide details  
Reply
post #9 of 12
Quote:
Originally Posted by FiX View Post
MYSQL would be good to use. It is easy to use as well.
There are only 3 commands you would normally need to use:
Code:
INSERT INTO (table here) VALUES (1, 2, 3, etc)
SELECT (variable or wildcard) FROM (table here)
DROP (table or database name)
I also made a php interpreter for .net as some mysql hosts dont allow the way the mysql connector for .net connects.
Same as MS SQL, which connects like a charm

Quote:
Originally Posted by kz26 View Post
Instead of VB, consider using Python + sqlite (an embedded database engine). Python comes with a sqlite module that is very easy to use, and its syntax is very similar to MySQL.

Learning a whole new language is a bit of an overkill, the guy just want some sort of database
My Rig
(14 items)
 
Ex-wife's Rig
(15 items)
 
 
CPUMotherboardGraphicsRAM
Core i5 4460 AsRock H81M-DG4 Sapphire Rx470 Platinum KVR 1600 16Gb 
Hard DriveHard DriveCoolingOS
2x Seagate 3Tb Samsung 850 EVO 120 Scythe Ninja 3 Rev.B Windows 10 Pro 
MonitorKeyboardPowerCase
Fujitsu Siemens A17-2A Logitech K280e SuperFlower SF-550K12XP Thermaltake Versa H25 
MouseAudio
Logitech G402 Sony MDR XD150 
CPUMotherboardGraphicsRAM
Athlon 750K 4.0Ghz AsRock FM2A75 Pro4+ Sapphire R9 270X Dual-X Kingston 2x4Gb 1600 
Hard DriveHard DriveOptical DriveCooling
Samsung 850 EVO 120  Western Digital 320Gb LiteON DVD-RW CoolerMaster Hyper Z600 
OSMonitorKeyboardPower
Windows 7 Pro x64 Toshiba 32" FullHD TV Logitech FSP Hexa 550 
CaseMouse
DeLUX Logitech 
  hide details  
Reply
My Rig
(14 items)
 
Ex-wife's Rig
(15 items)
 
 
CPUMotherboardGraphicsRAM
Core i5 4460 AsRock H81M-DG4 Sapphire Rx470 Platinum KVR 1600 16Gb 
Hard DriveHard DriveCoolingOS
2x Seagate 3Tb Samsung 850 EVO 120 Scythe Ninja 3 Rev.B Windows 10 Pro 
MonitorKeyboardPowerCase
Fujitsu Siemens A17-2A Logitech K280e SuperFlower SF-550K12XP Thermaltake Versa H25 
MouseAudio
Logitech G402 Sony MDR XD150 
CPUMotherboardGraphicsRAM
Athlon 750K 4.0Ghz AsRock FM2A75 Pro4+ Sapphire R9 270X Dual-X Kingston 2x4Gb 1600 
Hard DriveHard DriveOptical DriveCooling
Samsung 850 EVO 120  Western Digital 320Gb LiteON DVD-RW CoolerMaster Hyper Z600 
OSMonitorKeyboardPower
Windows 7 Pro x64 Toshiba 32" FullHD TV Logitech FSP Hexa 550 
CaseMouse
DeLUX Logitech 
  hide details  
Reply
post #10 of 12
There are many time to do so. One easy way is to utilize native ADO.Net xml file. You can take a look at the VB ado.net section. I typed this as it goes so need to check syntax.

1.Create a dataset and datatable object. Easy.
Code:
Dim ds as new dataset(“MyDatabaseâ€)
Dim dt as new datatable(“MyFirstTableâ€)
Ds.tables.add(dt)
2.Complete the table definition.
Code:
Dim dc1 as new datacolumn
Dim dc2 as new datacolumn
Populate the size and datatype. Then add to table
Code:
Dt.columns.add(dc1)
Dt.columns.add(dc2)
3.Insert new records
Code:
Dim newrow as datarow=dt.newrow()
Newrow.item(0).value=value1
Newrow.item(1).value=value2
Dt.rows.add(newrow)
Loop to add initial new records. When this done, save records
Code:
Dt.acceptchanges
4.Save it to a xml file. Easy.
Code:
Ds.savexml(“c:\\myfile.xmlâ€)

So you put that xml file in your application directory when you deploy. The easy way is to open a setup project to create a setup package and add this xml file as part of setup package.

When applications runs, if you want to access the data, all need to do is
Code:
Dim ds as new dataset()
Ds.readxml(“c:\\myfile.xmlâ€)
To use rows, put in this
Code:
Me.textbox1.text=ds.tables(0).rows(0).item(0).value
Want to save value.
Code:
ds.tables(0).rows(0).item(0).value= Me.textbox1.text
ds.acceptchange()
Save new data and changes back to xml file.
Code:
Ds.savexml(“c:\\myfile.xmlâ€)
If security is a factor, then all you need to do is to use .net built-in cryptograph library. Encrypt data when you save and decrypt them before you read xml file. It probably another 20 lines or so code. I am assuming you are using vb.net. Otherwise, if you use vb6, you may use ado 2.5 and above.
Edited by linskingdom - 1/10/11 at 8:25am
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › How to put Database in program (Not Access)