Avatar billede grandmaster Nybegynder
13. maj 2002 - 13:50 Der er 10 kommentarer og
1 løsning

Resultset

Hvordan for man via en setText(subString) til at vise det første/aktuelle resultat og bagefter bladre frem og tilbage?

Er det bare subString(1) / subString(1, 1), og derefter rs.next()?

Avatar billede proaccess Nybegynder
13. maj 2002 - 13:55 #1
du skal have fat i noget a'la

rs.MoveNext
Avatar billede terry Ekspert
13. maj 2002 - 14:04 #2
grandmaster where are we ASP?
Avatar billede grandmaster Nybegynder
13. maj 2002 - 14:19 #3
Nej det er i java, jeg skal have at vide om når man siger rs.substring(1) får fat i den aktuelle string som evt. stammer fra et resultset ELLER om man skal sige f.ek.s. rs.substring(1,1)... Jeg skal have fat i den samme række men flere oplysninger i den række!
Avatar billede grandmaster Nybegynder
13. maj 2002 - 14:19 #4
Som skal ind i forskellige felter.....
Avatar billede terry Ekspert
13. maj 2002 - 14:20 #5
ADO?
Avatar billede terry Ekspert
13. maj 2002 - 14:33 #6
not quite sure I understand!

You have selected one or more records and one of the fields contains data which you want into your progrem, or is it the GetString method you are thinking of?

// BeginGetStringJ
// The WFC class includes the ADO objects.
import com.ms.wfc.data.*;
import java.io.* ;

public class GetStringX
{
    // The main entry point for the application.

  public static void main (String[] args)
  {
      GetStringX ();
      System.exit(0);
  }

  // GetStringX  function
  static void GetStringX()
  {
      // Define ADO Objects.
      Connection cnConn1 = null;
      Recordset rstAuthors = null;

      // Declarations.
      BufferedReader in =
        new BufferedReader (new InputStreamReader(System.in));
      String strCnn = "DSN=Pubs;Provider=MSDASQL;uid=MyUserId;pwd=MyPassword;";
      String strOutput;

      try
      {
        // Get the user input for state.
        System.out.println(
            "Enter a state (CA, IN, KS, MD, MI, OR, TN, UT): ");
        String strState = in.readLine().trim();
        String strQuery =
            "SELECT au_fname, au_lname, address, city FROM Authors " +
                    "WHERE state = '" + strState + "'";

        // Open recordset with data from Authors table.
        cnConn1 = new Connection();
        cnConn1.open(strCnn);
        rstAuthors = new Recordset();
        rstAuthors.open(strQuery,
                cnConn1,
                AdoEnums.CursorType.STATIC,
                AdoEnums.LockType.READONLY,
                AdoEnums.CommandType.TEXT);

        if (rstAuthors.getRecordCount() > 0)
        {
            // Use all defaults: get all rows, TAB column delimiter,
            // CARRIAGE RETURN
            // row delimiter, empty-string null delimiter.
            strOutput =
              rstAuthors.getString(AdoEnums.StringFormat.CLIPSTRING,
              rstAuthors.getRecordCount(),
              "\t ",
              "\n",
              "").trim();
            System.out.println("\nState = '" + strState + "'" +
              "\n\n" +
              "Name            Address            City" +
              "\n");
            System.out.println(strOutput);
        }
        else
            System.out.println("\nNo rows found for state = '" +
              strState + "'\n");

        // Cleanup objects before exit.
        rstAuthors.close();
        cnConn1.close();

        System.out.println("\nPress <Enter> to continue..");
        in.readLine();
      }
      catch( AdoException ae )
      {
        // Notify user of any errors that result from ADO.

        // As passing a Recordset, check for null pointer first.
        if (rstAuthors != null)
        {
            PrintProviderError(rstAuthors.getActiveConnection());
        }
        else
        {
            System.out.println("Exception: " + ae.getMessage());
        }
      }

      // System read requires this catch.
      catch( java.io.IOException je)
      {
        PrintIOError(je);
      }

  }

  // PrintProviderError Function

  static void PrintProviderError( Connection Cnn1 )
  {
      // Print Provider errors from Connection object.
      // ErrItem is an item object in the Connection&#8217;s Errors collection.
      com.ms.wfc.data.Error  ErrItem = null;
      long nCount = 0;
      int  i      = 0;

      nCount = Cnn1.getErrors().getCount();

      // If there are any errors in the collection, print them.
      if( nCount > 0);
      {
        // Collection ranges from 0 to nCount - 1
        for (i = 0; i< nCount; i++)
        {
            ErrItem = Cnn1.getErrors().getItem(i);
            System.out.println("\t Error number: " + ErrItem.getNumber()
              + "\t" + ErrItem.getDescription() );
        }
      }

  }

  // PrintIOError Function

  static void PrintIOError( java.io.IOException je)
  {
      System.out.println("Error \n");
      System.out.println("\tSource = " + je.getClass() + "\n");
      System.out.println("\tDescription = " + je.getMessage() + "\n");
  }
}
// EndGetStringJ
Avatar billede terry Ekspert
13. maj 2002 - 18:23 #7
and?
Avatar billede terry Ekspert
14. maj 2002 - 18:49 #8
Heyyyyy.....
Avatar billede terry Ekspert
17. maj 2002 - 18:11 #9
grandmaster isnt there something you have forgotten?
Avatar billede grandmaster Nybegynder
07. oktober 2002 - 12:09 #10
Sorry, here you are...satisfied???
Avatar billede terry Ekspert
07. oktober 2002 - 12:13 #11
That took some time, thanks anyway :o)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester