conflict between sqlserver and sqlserverCe

cirollo

Active Member
Licensed User
Longtime User
Hi, I opened a new thread because the old thread title can make confusion...

finally I made the connection from a winCE PDA using in SQL 2008 the main instance and installing on the device the proper SQLClient CAB.

But, after doing the last operation, now I see the connection, but I get this error message:

An error occured on sub _mainmodule_app_start.

The database file is locked
database is locked
Continue?

This is my sub app_start, I think is related to the table rilevazioni that is onboard the device (is a sqllite table)
Infact, my program uses a local table to store data, that are transferred to the remote (network) sql at the user wish.

If I comment the lines regarding this local table, everything works, but this cannot be the desidered functionality.

Any idea about this error?




B4X:
Sub App_Start
    CreateConnection        
    Main.Show
    rigasel=""
    gestlotti="NO"
    svart="NO"
    gestubi="NO"
    ' leggiamo il numero del terminalino
    ' leggo dal file di testo i parametri per comporre la stringa di connessione al db remoto
    If FileExist ("param.txt") = True Then
        FileOpen (c1,"Param.txt",cRead ,, cASCII)
        r = FileRead (c1)    
        Do Until r = EOF
            Select SubString (r,0,3)
            Case "NUM"
                numterm = SubString (r,3,StrLength (r)-3)
            Case "LOT"
                gestlotti = SubString (r,3,StrLength (r)-3)
            Case "SVA"
                svart = SubString (r,3,StrLength (r)-3)
            Case "UBI"
                gestubi = SubString (r,3,StrLength (r)-3)
            Case "SVR"
                SVR = SubString (r,3,StrLength (r)-3)
            Case "USR"
                USR = SubString (r,3,StrLength (r)-3)
            Case "PWD"
                PWD = SubString (""&r,3,StrLength (r)-3)
            Case "DBN"
                DBN = SubString (""&r,3,StrLength (r)-3)
            Case "AZI"
                AZI = SubString (""&r,3,StrLength (r)-3)
            Case "MAG"
                MAG = SubString (""&r,3,StrLength (r)-3)
            Case "SER"
                SER = SubString (""&r,3,StrLength (r)-3)
            End Select
            r = FileRead (c1)
        Loop
        FileClose (c1)
    End If
    If SVR <> "NO" Then
        'apro la connessione con il db remoto
        stringaconn="Persist Security Info=False;Integrated Security=False;Server="&SVR &",1433;initial catalog=" &DBN &";user id="&USR &";password="&PWD&";"
    '    stringaconn="Data Source=192.168.7.201,1433;Network Library=DBMSSOCN;initial catalog=" &DBN &";user id="&USR &";password="&PWD&";"
    '    Msgbox(stringaconn)
        Sql1.New1
        If Sql1.Open(stringaconn) Then
            LblDb.Visible = True
            LblDb.Width = 230
            LblDb.Text = "Server: "&SVR&":1433 - DB: "&DBN&" ("&AZI&")"
    '        Msgbox("Conessione al DB Stabilita con Successo!!!","My First Program",cMsgboxYesNo,cMsgboxHand)
        Else    
    '           Msgbox("Impossibile Connettersi al DB!!!",progname,cMsgboxYesNo,cMsgboxHand)
    '        Msgbox(sql1.LastError,"")
            Msgbox("Impossibile Connettersi al DB!!!")
            main.Close
        End If
    End If
    label15.Text=label15.Text&" "&numterm
    ' riempiamo il combobox dell'operatore
    CmbOpe.Add ("...")
    CmbOpe.Add ("1")
    CmbOpe.Add ("2")
    CmbOpe.Add ("3")
    CmbOpe.Add ("4")
    CmbOpe.Add ("5")
    CmbOpe.Add ("6")
    CmbOpe.Add ("7")
    CmbOpe.Add ("8")
    CmbOpe.Add ("9")
    CmbOpe.SelectedIndex=1
    'nascondiamo il combo operatore
    label14.Visible=False
    cmbope.Visible=False
    'nascondiamo la label export
    label18.Visible=False
    ' verifichiamo se esiste la tabella
    Command1.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' AND name='t_rilevazioni'"
    Reader1.New1
    Reader1.Value = Command1.ExecuteReader
    If Reader1.ReadNextRow = False Then
       ' No table with this name in the database.
       ' Create one.
        Reader1.Close
        If gestlotti="NO" Then
            Command1.CommandText = "CREATE TABLE t_rilevazioni (Id STRING PRIMARY KEY,Barcode STRING,Qta STRING,Ubi STRING,Seriale STRING)"
        Else
            Command1.CommandText = "CREATE TABLE t_rilevazioni (Id STRING PRIMARY KEY,Barcode STRING,Lotto STRING,Qta STRING,Ubi STRING,Seriale STRING)"
        End If
        Command1.ExecuteNonQuery
    Else
        Reader1.Close
'        Command1.CommandText = "DROP TABLE t_rilevazioni"
'          Command1.ExecuteNonQuery
    End If
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…