- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
qr code generator c# source code note The chomp method added to gets removes the newline characters that appear at the end of in C#.NET
note The chomp method added to gets removes the newline characters that appear at the end of Make QR Code 2d Barcode In C# Using Barcode generation for .NET framework Control to generate, create Denso QR Bar Code image in .NET framework applications. www.OnBarcode.comDecode QR-Code In C# Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comkeyboard output retrieved with gets.
Paint EAN-13 In C# Using Barcode maker for .NET framework Control to generate, create EAN 13 image in .NET framework applications. www.OnBarcode.comMake EAN 128 In C# Using Barcode generator for VS .NET Control to generate, create EAN 128 image in Visual Studio .NET applications. www.OnBarcode.comThe start of the add_person method is mundane. You ask for each of the person s attributes in turn and assign them to variables. However, $db.execute is more intriguing this time. Matrix Barcode Drawer In C# Using Barcode encoder for VS .NET Control to generate, create Matrix Barcode image in Visual Studio .NET applications. www.OnBarcode.comEncoding Code 128A In Visual C# Using Barcode generator for .NET Control to generate, create Code 128A image in VS .NET applications. www.OnBarcode.comDownload at
Generating Linear In C#.NET Using Barcode drawer for .NET Control to generate, create Linear image in VS .NET applications. www.OnBarcode.comPainting MSI Plessey In Visual C#.NET Using Barcode maker for Visual Studio .NET Control to generate, create MSI Plessey image in VS .NET applications. www.OnBarcode.comC h a p t e r 9 F I Le S a N D D a t a B a S e S
Painting QR Code In None Using Barcode encoder for Online Control to generate, create QR Code image in Online applications. www.OnBarcode.comDecoding QR Code JIS X 0510 In Java Using Barcode decoder for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comIn the previous section, the INSERT SQL was shown with the data in the main statement, but in this method you re using question marks ( ) as placeholders for the data. Ruby performs an automatic substitution from the other parameters passed to execute into the placeholders. This acts as a way of securing your database. The reason is that if you interpolated the user s input directly into the SQL, the user might type some SQL that could break your query. However, when you use the placeholder method, the SQLite-Ruby library will clean up the supplied data for you and make sure it s safe to put into the database. Now you need a way to be able to access the data entered. Time for another method! This code example shows how to retrieve the associated data for a given name and ID: def find_person puts "Enter name or ID of person to find:" id = gets.chomp person = $db.execute("SELECT * FROM people WHERE name = OR id = ", id, id.to_i).first unless person puts "No result found" return end puts %Q{Name: #{person['name']} Job: #{person['job']} Gender: #{person['gender']} Age: #{person['age']}} end The find_person method asks the user to enter either the name or the ID of the person he or she is looking for. The $db.execute line cleverly checks both the name and id columns at the same time. Therefore, a match on either the id or name will work. If no match is found, the user will be told, and the method will end early. If there s a match, the information for that user will be extracted and printed on the screen. You can tie it up with a main routine that acts as a menu system for the four methods described earlier. You already have the database connection code in place, so creating a menu is simple: loop do puts %q{Please select an option: 1. 2. 3. 4. Create people table Add a person Look for a person Quit} UCC - 12 Encoder In None Using Barcode generator for Excel Control to generate, create UPC A image in Office Excel applications. www.OnBarcode.comUPC Code Reader In Java Using Barcode scanner for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comcase gets.chomp when '1' create_table
Drawing UCC - 12 In None Using Barcode generator for Office Word Control to generate, create EAN / UCC - 14 image in Office Word applications. www.OnBarcode.comPrinting PDF417 In Java Using Barcode printer for Eclipse BIRT Control to generate, create PDF-417 2d barcode image in BIRT reports applications. www.OnBarcode.comDownload at
Encoding Barcode In Java Using Barcode maker for Java Control to generate, create Barcode image in Java applications. www.OnBarcode.comData Matrix ECC200 Decoder In .NET Framework Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comCh apt er 9 FIL eS a ND Da ta B a S eS
Code 128 Code Set B Recognizer In .NET Framework Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comScan QR Code In None Using Barcode reader for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comwhen '2' add_person when '3' find_person when '4' disconnect_and_quit end end If the code is put together properly and then run, a typical first session could go like this: Please select an option: 1. Create people table 2. Add a person 3. Look for a person 4. Quit 1 Creating people table Please select an option: 1. Create people table 2. Add a person 3. Look for a person 4. Quit 2 Enter name: Fred Bloggs Enter job: Manager Enter gender: Male Enter age: 48 Please select an option: 1. Create people table 2. Add a person 3. Look for a person 4. Quit 3 Enter name or ID of person to find: 1 Name: Fred Bloggs Job: Manager Gender: Male Age: 48 Generate Universal Product Code Version A In VB.NET Using Barcode creator for Visual Studio .NET Control to generate, create UPC-A Supplement 5 image in .NET framework applications. www.OnBarcode.comCode 39 Reader In Java Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comDownload at
C h a p t e r 9 F I Le S a N D D a t a B a S e S
Please select an option: 1. Create people table 2. Add a person 3. Look for a person 4. Quit 3 Enter name or ID of person to find: Jane Smith No result Your quick and basic application provides a way to add data and retrieve data from a remote data source in only a handful of lines! Connecting to Other Database Systems
In the previous section, we looked at SQL and how to use it with the SQLite library, a library that provides a basic database system on the local machine. More commonly, however, you might want to connect to more mainstream database servers, such as those running on MySQL, PostgreSQL, MS SQL Server, or Oracle. In this section, we ll look quickly at how to connect to each of these types of databases. note A library called DBI is available that provides a database-agnostic interface between Ruby and database systems. In theory, you can write a program that talks with any database, and easily switch between different types of databases as long as you use DBI. In practice, this isn t always possible, but learning how to use DBI can give you access to using MySQL, PostgreSQL, and Oracle in the future. Links to a number of resources about DBI are supplied in Appendix C.
|
|