Didn't store values on DataBase file

Apr 20, 2010 at 5:50 PM

Hi,

I Use below code to create db file:


        Dim Conn As DbConnection = New EfzConnection("Connection Type=File ; Initial Catalog=NorthwindEF4; User=sa; Password=;")
        Conn.Open()

        Dim Cmd As EfzCommand = New EfzCommand(Conn)
        Cmd.CommandText = "CREATE TABLE Test(ID INT PRIMARY KEY, Name VARCHAR(100));"
        Cmd.ExecuteNonQuery()

        For i As Integer = 0 To 100
            Cmd.CommandText = "INSERT INTO Test(ID , Name) VALUES(" & i & " , " & i & ");"
            Cmd.ExecuteNonQuery()
        Next

        Dim cmdString As String = "SELECT Test.* FROM Test"

        Cmd.CommandText = cmdString


        Dim dr As EfzDataReader = Cmd.ExecuteReader(Data.CommandBehavior.CloseConnection)

        Dim stBuild As New StringBuilder

        While dr.Read
            stBuild.Append(dr.Item("ID") & vbTab)
            stBuild.Append(dr.Item("Name") & vbNewLine)
        End While 

        TextBox1.Text = stBuild.ToString

        Cmd.Dispose()
        Conn.Close()
        Conn.Dispose()


It's work good.Then I try to read values in created db file, again. I can connect to db file successfully. But I can not read any value from it. The reader is empty.

What is wrong? What I must do, which I forget it?

Thanks

Apr 20, 2010 at 7:15 PM
Edited Apr 20, 2010 at 7:16 PM

I find what is wrong. The default setting for commit is false. Just need to put auto "commit=true on" connection string.

Coordinator
Apr 21, 2010 at 1:19 AM

Hi,

Good that it worked!  But I guess better we make autocommit as default from next release.

-thanks