| DotNetFirebird Using Firebird SQL in .NET. |
|
Home
Features
Download
Documentation
Developer's Documentation
Connection String Parameters
Using FbConnectionStringBuilder to Build a Connection String
Connection Pooling
Create a New Database From an SQL Script
Using FbDataAdapter to Fill a Dataset
Firebird and .NET Framework Data Types Mapping
BIGINT Reading Example (C#)
BLOB Reading Example (C#)
BLOB SUB_TYPE 1 Reading Example (C#)
CHAR Reading Example (C#)
DATE Reading Example (C#)
DECIMAL Reading Example (C#)
DOUBLE PRECISION Reading Example (C#)
FLOAT Reading Example (C#)
INTEGER Reading Example (C#)
NUMERIC Reading Example (C#)
SMALLINT Reading Example (C#)
TIME Reading Example (C#)
TIMESTAMP Reading Example (C#)
VARCHAR Reading Example (C#)
Transaction Isolation Levels
Embedded Firebird Documentation
Performance Tuning
Security
Administration
Migration to Firebird
Sample Code
FAQ
Tools and Code
About
Blog
|
SMALLINT Reading Example (C#)TEST.SQL Script (Testing Database)Run the following script to create the testing database. It creates a simple table called MYTABLE with a single row. (How to create a database from an SQL script): CREATE TABLE MYTABLE (
ID INTEGER,
VAL SMALLINT
);
INSERT INTO MYTABLE (ID, VAL) VALUES (1, 123);
Reading valuesThe following sample prints the values from the column "VAL" to console: string database = "test.fdb";
CreateEmbeddedDb(database, "test.sql");
FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
csb.ServerType = 1;
csb.Database = database;
using (FbConnection c = new FbConnection(csb.ToString()))
{
c.Open();
FbCommand cmd = new FbCommand("SELECT val FROM mytable", c);
using (FbDataReader r = cmd.ExecuteReader())
{
while (r.Read())
{
short val = r.GetInt16(0);
Console.WriteLine("Value: " + val);
}
}
}
Copyright © 2005 - 2007 DotNetFirebird |