Quantcast

Create Database Tables

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Create Database Tables

Clyde Eisenbeis
To create a table:
-----------------------------
    int iTablesCount = liststTableNames.Count();
    try {
        string stOpenConn = new FbConnectionStringBuilder {
            Database = stPathFilename,
            UserID = stUserID,
            Password = stPassword,
            ServerType = FbServerType.Embedded,
            ClientLibrary = stCLIENT_LIBRARY
        }.ToString();
        FbConnection fbConn = new FbConnection(stOpenConn);
        fbConn.Open();

        FbTransaction fbTransaction = fbConn.BeginTransaction();
        for (int ii = 0; ii < iTablesCount; ii++) {
            string stSql = "CREATE TABLE " + liststTableNames[ii] + "(
" + liststFieldDefinitions[ii] + ")";
            FbCommand fbCmd = new FbCommand(stSql, fbConn, fbTransaction);
            fbCmd.ExecuteNonQuery();
        }
        fbTransaction.Commit();
-----------------------------
where stSql = "CREATE TABLE  TableOrg (  fstPriority VARCHAR(10),
fstInfo VARCHAR(100), fiKeyID INTEGER PRIMARY KEY )".

1) Is it correct to have multiple fbCmd.ExecuteNonQuery() commands ...
followed by one fbTransaction.Commit()?

2) I want to be able to handle German vowels, such as umlauts, for
fstInfo.  I don't think VARCHAR is the correct choice as it is
non-unicode.

3) I also want variable lengths, without a max, for fstInfo.  What do
I use in place of the "100"?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create Database Tables

Jiří Činčura-2
> 1) Is it correct to have multiple fbCmd.ExecuteNonQuery() commands ...
> followed by one fbTransaction.Commit()?

Yes. Also use `using` block for disposable resource.

> 2) I want to be able to handle German vowels, such as umlauts, for
> fstInfo.  I don't think VARCHAR is the correct choice as it is
> non-unicode.

You can use CHARACTER SET clause. Best is probably to use UTF8.
 
> 3) I also want variable lengths, without a max, for fstInfo.  What do
> I use in place of the "100"?

Then you have to use BLOB SUB_TYPE TEXT.

--
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create Database Tables

Clyde Eisenbeis
1) It's not obvious to me where to put the 'using' with 'try'.  Could
you provide an example using the code in my first email?

2) Is this what you recommend?

where stSql = "CREATE TABLE  TableOrg (  fstPriority VARCHAR(10),
fstInfo VARCHAR(x) CHARACTER SET UNICODE_FSS, fiKeyID INTEGER PRIMARY
KEY )".

What do I use for 'x'?  This should be variable.

3)  BLOB SUB_TYPE TEXT is non-Unicode.  The field 'fstInfo' needs to
handle German.

On Thu, Mar 23, 2017 at 2:11 AM, Jiří Činčura <[hidden email]> wrote:

>> 1) Is it correct to have multiple fbCmd.ExecuteNonQuery() commands ...
>> followed by one fbTransaction.Commit()?
>
> Yes. Also use `using` block for disposable resource.
>
>> 2) I want to be able to handle German vowels, such as umlauts, for
>> fstInfo.  I don't think VARCHAR is the correct choice as it is
>> non-unicode.
>
> You can use CHARACTER SET clause. Best is probably to use UTF8.
>
>> 3) I also want variable lengths, without a max, for fstInfo.  What do
>> I use in place of the "100"?
>
> Then you have to use BLOB SUB_TYPE TEXT.
>
> --
> Mgr. Jiří Činčura
> https://www.tabsoverspaces.com/
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Firebird-net-provider mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create Database Tables

Clyde Eisenbeis
1) I think it would be

    string stOpenConn = new FbConnectionStringBuilder {
        Database = stPathFilename,
        UserID = stUserID,
        Password = stPassword,
        ServerType = FbServerType.Embedded,
        ClientLibrary = stCLIENT_LIBRARY
    }.ToString();
    using (FbConnection fbConn = new FbConnection(stOpenConn)) {
        try {
            fbConn.Open();

On Thu, Mar 23, 2017 at 8:30 AM, Clyde Eisenbeis <[hidden email]> wrote:

> 1) It's not obvious to me where to put the 'using' with 'try'.  Could
> you provide an example using the code in my first email?
>
> 2) Is this what you recommend?
>
> where stSql = "CREATE TABLE  TableOrg (  fstPriority VARCHAR(10),
> fstInfo VARCHAR(x) CHARACTER SET UNICODE_FSS, fiKeyID INTEGER PRIMARY
> KEY )".
>
> What do I use for 'x'?  This should be variable.
>
> 3)  BLOB SUB_TYPE TEXT is non-Unicode.  The field 'fstInfo' needs to
> handle German.
>
> On Thu, Mar 23, 2017 at 2:11 AM, Jiří Činčura <[hidden email]> wrote:
>>> 1) Is it correct to have multiple fbCmd.ExecuteNonQuery() commands ...
>>> followed by one fbTransaction.Commit()?
>>
>> Yes. Also use `using` block for disposable resource.
>>
>>> 2) I want to be able to handle German vowels, such as umlauts, for
>>> fstInfo.  I don't think VARCHAR is the correct choice as it is
>>> non-unicode.
>>
>> You can use CHARACTER SET clause. Best is probably to use UTF8.
>>
>>> 3) I also want variable lengths, without a max, for fstInfo.  What do
>>> I use in place of the "100"?
>>
>> Then you have to use BLOB SUB_TYPE TEXT.
>>
>> --
>> Mgr. Jiří Činčura
>> https://www.tabsoverspaces.com/
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Firebird-net-provider mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Loading...