7 Replies Latest reply on Apr 15, 2008 2:45 AM by Shakazulu89

    help with sqlconnection!!

    Shakazulu89
      hello hello
      i am fairly new to flex, but have read a lot and know where to get help resources from..
      i couldnt figure out why ive been getting this error:

      i am trying to set up a connectiong to SQLdb file that ive created using SQL..
      it is called TimeLog..
      This is the code i used:

      import flash.data.SQLConnection;
      import flash.data.SQLMode;
      import flash.events.SQLErrorEvent;
      import flash.events.SQLEvent;
      import flash.filesystem.File;


      public var conn:SQLConnection = new SQLConnection();
      public var timeLogsDB:File = new File("C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TimeLog");

      try
      {
      conn.open(timeLogsDB , SQLMode.UPDATE);
      trace("the db opened!!");
      }
      catch (error:SQLError)

      {
      trace("Error Message:" , error.message);
      trace("Details:" , error.details);
      }

      and the error i get is on the first line after the try statement:
      error 1120 access of undefined property conn
      error 1120 access of undefined property timeLogsDB

      can someone please help me here.. the only thing i can think of is that im pointing to the file directory the wrong way ...
      anyway any help would be appreciated...
      thanks :)
        • 1. Re: help with sqlconnection!!
          justria Level 1
          Beforehand, a short note, that you can open SQLite DBs, no DB files from other DB systems. Especiall, you can't connet to MS SQL server or those files MS SQL Server created.

          In general, you code is fine.

          I'd propose to simplify

          >>>
          public var timeLogsDB:File = new File("C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TimeLog");
          <<<

          like this:

          >>>
          public var timeLogsDB:File = new File("C:\TimeLog");
          <<<

          Does this work for you?
          • 2. Re: help with sqlconnection!!
            justria Level 1
            I forgot one thing: SQL* ist available in AIR applications, not in Flex apps running in your browser.
            • 3. Re: help with sqlconnection!!
              Shakazulu89 Level 1
              so you are saying that the problem is that im using a db that i created with MSSQL when AIR only accepts DBs created by SQLLite?

              changing to the line doesnt do anything.. same error.. but thanks i didnt know i could just write it the short way and itll find it by itself :)

              so should i just use SQLLite and it should be fine?
              and what do you mean SQL isnt available for AIR applications??
              if so then how do i work with a DB withing an AIR app?
              • 4. Re: help with sqlconnection!!
                justria Level 1
                quote:

                so should i just use SQLLite and it should be fine?
                and what do you mean SQL isnt available for AIR applications??
                if so then how do i work with a DB withing an AIR app?


                Hm, sorry, probably my english isn't that good. I'm no native speaker. Let's try again anyway ;-)

                SQLLite is only available, if you build an AIR application. In general, you can't use it in Flex app, which you deploy using a browser.

                Although SQLite is a single-user flat-file database system [no server required], it is quite fast and conforms quite good to SQL standards. Thus, using SQLite should be just fine for most applications.

                Additionally, I tried to explain, that SQLite isn't able to use MySQL, MS SQL or Oracle datasstores.

                PS: You might enable a FLEX app and an AIR app to talk to each other. This way, you could enrich a Flex browser app to use SQLite by means of an AIR proxy app.
                • 5. Re: help with sqlconnection!!
                  Shakazulu89 Level 1
                  the thing is that this is an AIR App, and i do want the database to be on a server..
                  i dont understand why it is giving me that error
                  its like as if it is saying that it doesnt recognize the variable declaration..
                  can you think of a possible reason for such a thing?
                  i still dont understand though: with an AIR application can i only use a database created with SQLLite or does it work with MySQL and MSSQL as well?
                  • 6. Re: help with sqlconnection!!
                    Shakazulu89 Level 1
                    hey i think i know what the problem is..
                    maybe its because in this line :
                    public var timeLogsDB:File = new File("C:\TimeLog");

                    it is creating a NEW file, but the file i want to open has already been created with SQL.. so i dont want AIR to create a new DB ..
                    could that be the problem or AIR recognizes this automatically and the same code is used to create a new database and point to an already created database..

                    i hope you understand .. english is also not my native language :)
                    • 7. Re: help with sqlconnection!!
                      Shakazulu89 Level 1
                      nevermind heh... i dont think thats the problem..
                      do you have any further insight that could be helpful to me?