Announcement

Collapse
No announcement yet.

SQL to retrieve user record based on a string variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL to retrieve user record based on a string variable

    Pls I really need help.

    I have a login system that displays user name at the top, and I have an SQLite database with users details such as record ID, Name, Photo (path). I want if that user name "displayed" matches a user name in the database table, then his detail such as Name and Photo path should be loaded to the respective objects on the page.

    I have no issues saving the user detail (Name, Photo path) to the database. My problem is how to retrieve based on the displayed name "label text".

    Thanks in anticipation. I really need assistance on this, some sample code will really help.

  • #2
    You need to build a query to retrieve the desired record from the database. Unless you post the project and the database, nobody will be able to guess what the proper syntax would be.

    I see you asking lots of questions here for your project. It may be more productive contracting somebody to write the missing code for your project.

    Ulrich

    Comment


    • #3
      Database Query

      I think you might be looking for something like this:

      -- Get name to search database for from screen label text
      tblProp = DlgStaticText.GetProperties(CTRL_STATICTEXT_LABEL_ 01);

      -- Open database
      nResult = ODBC.OpenDirectConnection(strConnectString, "auto", 1);
      if (nResult == 0) then
      tblResult = ODBC.QueryToTable("SELECT Id, Name, Photo FROM DatabaseName WHERE Name = '"..tblProp.Text.."'", 1);
      if (tblResult ~= nil) then
      if (Table.Count(tblResult) > 1) then
      --[[
      Row 1 contains column names returned
      Row 2 .. ?? contains data for each column.
      sMsg = "Row count = "..Table.Count(tblResult).."\r\n";
      for row, record in pairs(tblResult) do
      sMsg = sMsg.."Row "..row.." Column count = "..Table.Count(record).."\r\n";
      for col, field in pairs(record) do
      sMsg = sMsg.."Row "..row..", Column "..col.." Value = "..field.."\r\n";
      end
      end
      Dialog.Message("QueryToTable Result", sMsg);
      ]]
      end
      end
      end

      Comment


      • #4
        Re: SQL to retrieve user record based on a string variable

        Ok Thank you all for following me up. As suggested attached is the project file with the database. What i want is user details should be retrieved based on the UserName displayed on top eg Facebook, instead of the ID. If you change the ID number lets say to 3 in the project, it will retrieve the user details of that ID and load into the respective objects. that is what i want the user name to do. Let it recognize strings instead of numbers.

        Great thanks in anticipation.
        Attached Files

        Comment


        • #5
          Re: SQLite Photo Display

          Originally posted by Ulrich View Post
          You need to build a query to retrieve the desired record from the database. Unless you post the project and the database, nobody will be able to guess what the proper syntax would be.

          I see you asking lots of questions here for your project. It may be more productive contracting somebody to write the missing code for your project.

          Ulrich
          I have Posted the Project file which include the database, if you run the project you will see what iam taking, then change the label number 4 or 2 you will see a new picture and its detail. I want it achieved as explained below.

          Comment


          • #6
            Re SQLite to retrieve and display pic

            Originally posted by Ulrich View Post
            You need to build a query to retrieve the desired record from the database. Unless you post the project and the database, nobody will be able to guess what the proper syntax would be.

            I see you asking lots of questions here for your project. It may be more productive contracting somebody to write the missing code for your project.

            Ulrich
            I updated the project file cos it seem to me the one i earlier uploaded is not showing the picture as u change the value at the top, but this one does.
            Attached Files

            Comment


            • #7
              Ire ally need help on this issue, can anybody give me some headway? If only I had cash, I could have contracted as Ulrich earlier suggested.

              Comment


              • #8
                I have fixed the project for you.

                Ulrich
                Attached Files

                Comment

                Working...
                X