Databases and applets

I am able to get a database connection working with an applet in java 2, v1.4, but it requires a plugin. Does anyone know how to get this working without the plugin? I would like it to be accessible by browsers that do not have the plugin.
Thank you,
Andrea

I am using IE 5.5 and java 2, v1.4 (the latest version). Using jdbc I was successfully able to write the contents of the database to the applet.
Unfortunately, I cannot seem to get my program to work unless I have the latest java plugin (java runtime environment). I do not want all the users who access my site to have to download the plugin.
If it is done on the server side (perhaps with a Servlet), is the plugin necessary?
Thanks
Andrea

Similar Messages

  • Urgent : store and retrieve image to oracle database thru applet

    hi all
    i want the code sample for storing the image to oracle database
    development enviornment:
    server : oracle 9i , apache web server
    client : ie6 browser
    i am connecting to oracle database thru applet using oracle jdbc thin driver
    can anyone give me details about storing image to db
    1) what datatype should be used in table for image?
    2) my image files are on client machine... can i directly read those files from browser or first i have to copy those files to server?
    3) .gif files will do or what should be the fileformat?
    4) java code to store it to database (i am using jdk1.3)
    5) how to retrieve it back from database and display it in awt panel ?
    its very urgent ...
    i am doing some r&d and trying to do using blob....
    but it will take some time ...
    i will really be thankful if someone sends detail code....
    thankx in advance ....

    Hi,
    The code below might answer few of your questions.
    There is a restrcition on size of image, it must be less than 4KB.
    //Code to insert image in database
    //mytable is the table name that contains two fields in databse:name,image of type varchar and blob
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con =null ;
    Statement stmt =null ;
    con =DriverManager.getConnection  ("jdbc:oracle:thin:@<hostname>:1521:orclsid", "system","manager");
    PreparedStatement preparedStatement = con.prepareStatement("insert into mytable (name,image) values (?,?)");
    preparedStatement.setString(1,"Amol");
    InputStream inputStream = new BufferedInputStream(new FileInputStream("C:\\WINNT\\Temp\\netscape\\images\\menubg.jpg"));
    preparedStatement.setBinaryStream(2, inputStream, inputStream.available());
    preparedStatement.executeUpdate();
    preparedStatement.close();
    inputStream.close(); To retrieve image,here is the snippet
    ResultSet resultSet = stmt.executeQuery("select image from mytable'");
    if (resultSet.next())
    byte[] image1 = resultSet.getBytes("image");
    FileOutputStream fos=new FileOutputStream("c://splash11.jpg"); //will retrieve bytes and create a file
    //by the name specified
    fos.write(image1);
    -Amol

  • Hi nid help with database and web

    hi to all! i wanted to get some help on how to connect to a database in a web... i dont know if its javascript,java applet,or jsp... could some1 pls give me a code on how to make a simple login database connection in a web through java.. i really nid it guys... we have our contest next week... pls.. i really nid your help... tnx!

    hi to all! i wanted to get some help on how to
    connect to a database in a web... what do you know about databases and the web today?
    i dont know if its
    javascript,java applet,or jsp... yes.
    could some1 pls give
    me a code on how to make a simple login database
    connection in a web through java.. (1) create a table USER in your favorite relational
    database - id, username, and password should be
    enough.
    (2) Use HTML to create a login form - username and
    password text fields and a submit button will be
    good.
    (3) Write a JSP using JSTL <sql> tags to query the
    database and put the result into request scope.
    (4) Redirect to a success JSP to demonstrate a
    successful login, or back to the login if it fails.
    i really nid itI hope this helps.
    guys... we have our contest next week... pls.. i
    really nid your help... tnx!What do "we" win? Will you be listing me as the sole
    developer if I write this for you?
    My rate is $120 USD per hour. Give a credit card
    number and I'll get right on it.<Actually its just a contest for our intramurals.. i was just hoping if u guys could help me ... thnx!

  • Database in Applet

    I use oracle as database, and i'm trying to show data from a table into applet form, but i've problem with accessing jdbc driver. I'm sure that my classpath and path setting are correct, and the errors are about AccessControlException and classLoader. I make this access but not in applet type and it works. Can you all help me and give me an example, cause this is my homeworks.

    This is due to the Default SecurityManager in Applet.If u run as a simple application u don't get any AcessControlException.
    By Default Applet is having its own SecurityManager and for Applications haven't.
    So two possiblities are there to acess the DataBase.One is by writing a permission file for the SecurityManager and add to the Envroinment.ie assigning permissions
    Other is write an servlet which retrives data from the database and the applet gets data from the
    servlet.This the the normal way which people are using.

  • JDBC and Applet communication

    HI!
    I am not able to connect my Oracle datbase in Applet.
    Please give ur suggestions.
    Thanx in Adv
    Vink

    Hi
    An applet can request a socket connection only to the server from which it is downloaded from.
    If your database and the webserver are running on different hosts then the applet security model restricts the applet from connecting to the database. You need to set the proper security policies and sign the applets.
    Refer the following link on applets
    http://developer.java.sun.com/developer/technicalArticles/Security/Signed/
    Also post the complete error/stack traces if you get into some problems.
    Hope this helps
    shrini

  • Access a database in applet

    2002-4-17 15:46
    I can run application program to handle a database ,
    But when I convert the code of application to the code of applet,
    then i run appletviewer ***.html;
    it tell me that it cant access the database ,
    "java.security.AccessControlException: access denied (java.lang.RuntimePermission
    accessClassInPackage.sun.jdbc.odbc)"
    why?
    How to resolve it!
    thanks

    This is due to the Default SecurityManager in Applet.If u run as a simple application u don't get any AcessControlException.
    By Default Applet is having its own SecurityManager and for Applications haven't.
    So two possiblities are there to acess the DataBase.One is by writing a permission file for the SecurityManager and add to the Envroinment.ie assigning permissions
    Other is write an servlet which retrives data from the database and the applet gets data from the
    servlet.This the the normal way which people are using.

  • Connecting to database through applet

    hi friends
    I am trying to connect to sql database through applet but I cant.
    in fact it can not connect to database.
    plz any body tell me how can i do this. Thanks

    // class depends on
    //     msbase.jar
    //     mssqlserver.jar
    //     msutil.jar
    // these api's are part of Microsoft SQL Server 2000 Driver for JDBC
    // allso need JNDI file system Service provider: found @ sun http://java.sun.com/products/jndi/#DOWNLOAD12 the JNDI 1.2.X class librarys and
    //          File system provider 1.2 beta 3
    //     fscontext.jar
    //     providerutil.jar
    //      (jndi.jar) provided in java > 1.3*
    // to compile:
    // javac -classpath "C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;C:\j2sdk1.4.2_01\jndi\lib\fscontext.jar;C:\j2sdk1.4.2_01\jndi\lib\jndi.jar;C:\j2sdk1.4.2_01\jndi\lib\providerutil.jar" SQLTest.java
    import javax.sql.*;
    import java.sql.*;
    import javax.naming.*;
    import java.util.Properties;
    public class SQLTest extends Thread {
        String sqlServerUser = "sql login account";
        String sqlServerPWD = "sql password";
        String sqlServerName = "sql machine";
        String sqlServerPort = "1433";
        public SQLTest() {
        public static void main(String[] args) {
            (new SQLTest()).run();
        public void run(){
            Connection conn = null;
            try{
                Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://" + sqlServerName + ":"+ sqlServerPort + ";User=" + sqlServerUser + ";Password=" + sqlServerPWD + ";ProgramName=JAVA-jdbc;DatabaseName=Northwind");
                Statement stmt = conn.createStatement();
                ResultSet result = stmt.executeQuery(
                    "SELECT * from [Shippers]"
                if(result.next()){
                    System.out.println(result.getString("CompanyName") + " " + result.getString("Phone"));
                    while(result.next()) {   // for each row of data
                        System.out.println(result.getString("CompanyName") + " " + result.getString("Phone"));
                System.out.println("Getting a connection with drivermanager works fine");
            } catch(Exception e){
                e.printStackTrace(System.out);
            } finally{
                try{
                    conn.close();
                } catch(Exception e){
                    e.printStackTrace(System.out);
            if(true){return;}
    // try it with a datasource
            try{
            // Setting the context:
                com.microsoft.jdbcx.sqlserver.SQLServerDataSource sds = new com.microsoft.jdbcx.sqlserver.SQLServerDataSource();
                sds.setServerName(sqlServerName);
                sds.setDatabaseName("Northwind");
                sds.setNetAddress(sqlServerPort);
                Properties p = new Properties();
                p.put(Context.INITIAL_CONTEXT_FACTORY,     "com.sun.jndi.fscontext.RefFSContextFactory");
                Context ctx = new InitialContext(p);
                try{
                    ctx.unbind("jdbc/EmployeeDB");
                }catch(Exception e){
                }finally{
                    ctx.bind("jdbc/EmployeeDB",sds);
                DataSource ds = (DataSource)ctx.lookup("jdbc/EmployeeDB");
                conn = null;
                conn = ds.getConnection(sqlServerUser,sqlServerPWD);
                Statement stmt = conn.createStatement();
                ResultSet result = stmt.executeQuery(
                    "SELECT * from [Shippers]"
                if(result.next()){
                    System.out.println(result.getString("CompanyName") + " " + result.getString("Phone"));
                    while(result.next()) {   // for each row of data
                        System.out.println(result.getString("CompanyName") + " " + result.getString("Phone"));
                System.out.println("works with datasource");
            } catch(Exception e){
                e.printStackTrace(System.out);
            } finally{
                try{
                    conn.close();
                } catch(Exception e){
                    e.printStackTrace(System.out);
    }To give an applet special privileges you can specify the prifs in the java.policy file or sign the applet and choose "yes I trust" or "yes I allways trust" when the applet is loaded.
    To give special prifs with the java.policy, it should look like this:
    grant {
    permission java.lang.RuntimePermission "usePolicy"; // prevents the popup from showing for signed applets
    grant codeBase "file:C:/-" {
      permission java.security.AllPermission;
    grant codeBase "http://localhost/-" {
      permission java.security.AllPermission;
    };

  • How to connect to the mysql database using applet from remote PC

    Hii All..
    I am also facing a problem.
    My web server and mysql server are running on the same PC.
    when i connect to the database from the same PC.
    Its connection but when i am trying to connect to the database from the different PC its giving error and not finding the driver "com.mysql.jdbc.Driver" because this is there on the server PC and applet runs on the client side..
    So to load the deriver on the client side so that it can run the applet to make the database connection on the remote PC.
    Thanks
    Uttam

    You are missing the library on the client.
    It must be moved to the client.
    Just like any other library that an applet requires.
    And that has nothing to do with JDBC.
    There are certainly way(s) to do it. Perhaps a forum that addresses applets, web usage or guis would provide an answer.

  • Logical Database and Logical Thing

    Hi,
    i want to access KONV which is cluster table and the field is KWERT.
    The thing is that i want to access it by taking customers from KNVV and giving it to VBRK (SALES Table). Now in VBRK i want to have a selection on FKDAT to get a list of Customers stored in the field called KUNAG.
    on VBRK-KUNAG basis i want to access the table KONV-KWERT.
    If i am doing queries then the System stops responding cuz it has got alot of overhead. So i tried to use Logical Database called VFV.
    If this is the best solution means using LDB then how to use it, can anyone help me with this. I tried it by Function module but it is showing all data without considering selection criteria.
    If anyone can help me then plz do answer or refer me to any web site so that i can figure this thing out. If anyione has got a good book on that then plz feel free to mail me.
    Thanks,
    Muhammad Usman Malik
    ABAP Consultant
    Siemens
    [email protected]
    +92-333-2700972

    Thanks Shibba that was very helpful, i applied that but the system overhead was so much.
    can u help me with Dynamic selection code.
    I used FREE_SELECTION_INIT, FREE_SELECTION_DIALOG and then FREE_SELECTIONS_RANGE_2_WHERE to get ther Selections in one table.
    if u want me to send u the code then i can do that cuz i am getting so much mad that this work is not done yet.
    The Scenario here is that we want to take BILLED Customers and VKORG as Industrial Billing Customer and then taking VBRK and giving all these Customers and then taking selection on FKDAT range.
    Now after that the data should be collected from KONV-KWERT and i want to perform some calculation over it. I am using VFV (Logical Database) to perform this thing because i know that it would be very fast then applying my own queries.
    If you can mail me any book on Logical Database and Dynamic selection then it will be very Helpful.
    Thanks once again for being such helpful.
    Muhammad Usman Malik
    SAP Consultant
    [email protected]
    +92-333-2700972

  • Reference to database and/or server name in '' is not supported in this version of SQL Server

    Hello all
    I am using C# and ADO.NET (native) - Visual Studio 2013.
    I am always using full qualified queries like "SELECT * FROM [database].[schema].[table]"
    Obviously there is a problem when doing this against SQL Azure,
    I get the following error: "Reference to database and/or server name in '' is not supported in this version of SQL Server"
    Interesting fact: With SQL Management Studio, the same query works.
    I need to know if this error is really a true one or not.
    If yes, I can quit using SQL Azure. I would need a SQL Server and not a partial SQL Server :-)
    Thanks and best regards
    Frank

    Hi,
    Here are my suggestions:
    1. Use partially qualified queries, because:
    a. from a security standpoint, you'd want to limit your login's access across the server instance
    b. in order to achieve a even better, you should specify your database as the Initial Catalog directly in the SQL Connection.
    If you take into account these practices, SQL Database doesn't come with any limitation from that point of view.
    However, in regard to 'With SQL Management Studio, the same query works', this is actually only partially true because if you run that query agains ADO.NET, you'll actually end up in switching databases along the query which is obviously not permitted in
    SQL Database since you're running in a hosted black-box version of SQL you're not managing. It's just like running the USE <dbname> command which obviously doesn't work.
    Alex

  • Jasper report on HTML when one image loaded from database and for the other

    How to generate jasper report on HTML when one image loaded from database and for the other we give a image path
    My code
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
              exporter = new JRHtmlExporter();
              exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
              exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
              exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, strImageInputDirectory);
         exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME, strImageOutputPath == null ? "." : strImageOutputPath);
         exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
         exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
         exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
              exporter.exportReport();
              byte[] bdata = ((ByteArrayOutputStream) baos).toByteArray();
    Can any one help pls
    Message was edited by:
    ameet.au

    hey sorry for posting it in this forum.
    but do u have sample code for making it work.. since i am able to do it on PDF format(image from Database and another stored in the webserver) using
    byte image[] =(byte[]) outData.get("image");
                        ByteArrayInputStream img = new ByteArrayInputStream(image);
                        hmimg.put("P_PARAMV3", img);
    print = JasperFillManager.fillReport(reportFileName, hmimg, jrxmlds);
    bdata= JasperExportManager.exportReportToPdf(print);

  • I m using ms access as database and i want to create a login page in java

    hye frnz... plz help me m new to java
    m using ms access as database and try to create a login page where user type username and pw
    i had enter valid user entries in database i checked connectivity is working i want as user login the main window must open after checking username and pw field to database but
    now there is an error class not found exception sun:jdbc...... error
    plz help me i had stuck frm 4 days */
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Login extends JFrame
    //Component Declarations
    JLabel jlb1,jlb2;
         JTextField jtf1;
         JPasswordField jpf1;
         JButton jb1,jb2;
         //Constructor
         Login()
         //frame settings
              setTitle("Login Dialog");
              setLayout(new GridBagLayout());
              GridBagConstraints gbc = new GridBagConstraints();
              setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              Dimension d= Toolkit.getDefaultToolkit().getScreenSize();
              setBounds(d.width/2-175,d.height/2-100,350,200);
              gbc.insets=new Insets(7,7,7,7);
         //adding components
              jlb1=new JLabel("User ID");
              gbc.gridx=0;
              gbc.gridy=0;
              add(jlb1,gbc);
              jlb2=new JLabel("Password");
              gbc.gridx=0;
              gbc.gridy=1;
              add(jlb2,gbc);
              jtf1=new JTextField(10);
              gbc.gridx=1;
              gbc.gridy=0;
              add(jtf1,gbc);
              jpf1=new JPasswordField(10);
              gbc.gridx=1;
              gbc.gridy=1;
              add(jpf1,gbc);
              jb1=new JButton("Login");
              gbc.gridx=0;
              gbc.gridy=2;
              add(jb1,gbc);
              jb1.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                   Connection conn=null;
                        Statement stmt=null;
                        boolean found=false;
                   try
                             Class.forName("sun.jdbc.driver.JdbcOdbcDriver");
                             String dataSourceName = "Inventory";
                             String dbURL = "jdbc:odbc:" + dataSourceName;
                             conn=DriverManager.getConnection(dbURL, "","");
                             stmt=conn.createStatement();
                             ResultSet rst=stmt.executeQuery("Select * from User");
                             System.out.println(jtf1.getText()+"/t"+jpf1.getPassword());
                             while(rst.next())
                                  System.out.println( rst.getString(1) +"/t"+ rst.getString(2));
              if(jtf1.getText().equals(rst.getString(1).trim()) && new String(jpf1.getPassword()).equals(rst.getString(2).trim()))
                                       found=true;
                                       rst.close();
                                       dispose();
                                       MainWindow mw= new MainWindow();     /*created min window object created to be opend after login but not working*/     
                                       break;
                             rst.close();
                             stmt.close();
                             conn.close();                    
                        catch(ClassNotFoundException e){System.out.print(e);}
                        catch(Exception e){System.out.print(e);}
                        if(found==false) /*this portion is executing and dialog box appears invalid name and pw with class not found exception sun:jdbc.......on console */
                             JOptionPane.showMessageDialog(null,"Invalid username or password",
                                  "Error Message",JOptionPane.ERROR_MESSAGE);
              jb2=new JButton("Clear");
              gbc.gridx=1;
              gbc.gridy=2;
              add(jb2,gbc);
              jb2.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        jtf1.setText("");
                        jpf1.setText("");
                        jtf1.requestFocus();
              setSize(350,200);
              setVisible(true);
              jtf1.requestFocus();
         public static void main(String args[])
    Login l=new Login();
    }

    http://forums.oracle.com/forums/ann.jspa?annID=599
    Oh, and by the way, your keyboard seems to be broken as your words are not getting spelled correctly.

  • Swapping between client database and web database

    Hi i have completed tutorials etc so can now create the
    sqlite database for my application which is downloaded by the user
    and will run on thier desktop so i am calling it the "client
    database" which contains data they are working with but there is
    another database containing identical tables which i am calling the
    "global database" the idea of this is to transfer data between the
    different clients and backup that information.
    so i am looking for a tutorial or a sample app where the app
    takes information from a web based database and copy's that rob
    into a sqlite database on the clients machine?
    this is the main problem im having and seen people mentioning
    blaze DS and stuff like that, ideally i wouldn't like to use PHP
    but atm is looking like i may have to.
    i will sell my soul to anyone who can help with this lol
    (also i am using FLEX 3.0)

    Hi,
    Yes, if you use LCDS everything is there already for you, so
    that you can complete this application in very less time. Since you
    want to use PHP, you can use Zend PHP, which will support Remoting
    using AMF. Using Zend PHP, write PHP classes which will help you to
    synchronize data between server and client and just invoke those
    from your Flex application when required.
    Hope this helps.

  • Database and Server Report

    Hi,
    I want to assist my friend (he is same like me, newbie in oracle) to give a report on health of oracle database and server; which is running in his small software development and data feeding company. There are around
    1. 50 users,
    2. windows XP professional,
    3. Oracle9i Enterprise Edition Release 9.2.0.1.0 – Production,
    4. one database, No Archive Mode, oracle home is : c:\oracle\ora92 and database is stored at D:\ORACLE\oradata\orcl, 3 control files, 3 redo groups and 11 dbfs
    5. 2.27 GB is free space on the drive of oracle home,
    6. more than 1 GB RAM is in the system,
    7. <what else more; I should describe, please let me know>
    He has to submit a report on current status, health, performance etc. of oracle database and server. How should we design and get the data, please guide me.
    Thanks & Regards

    You Mean Helath Check Report of the DB
    Tablespace size?
    Datafile Size?
    Default tablespace?
    UNDO management?
    SGA?
    buffer cache hit ratio?
    library cache hit ratio?
    There are so many other parameters..Performance cannot be predicted from remote site
    But you can provide certain information
    Here are some views which could be helpful
    DBA_TABLESPACE
    DBA_FREE_SPACE
    DBA_DATA_FILES
    V$CONTROLFILE
    V$LOG--Meaning less since you run in archived mode
    Number of Oracle Process allocated
    UNDO RETENTION
    SQL>show parameter process
    SQL>show parameter UNDO
    Do you have METALINK acces
    1019546.6
    this has everything then you can pass whatever they need
    and many more

  • Powershell use Connection String to query Database and write to Excel

    Right now I have a powershell script that uses ODBC to query SQL Server 2008 / 2012 database and write to EXCEL
    $excel = New-Object -Com Excel.Application
    $excel.Visible = $True
    $wb = $Excel.Workbooks.Add()
    $ws = $wb.Worksheets.Item(1)
    $ws.name = "GUP Download Activity"
    $qt = $ws.QueryTables.Add("ODBC;DSN=$DSN;UID=$username;PWD=$password", $ws.Range("A1"), $SQL_Statement)
    if ($qt.Refresh()){
    $ws.Activate()
    $ws.Select()
    $excel.Rows.Item(1).HorizontalAlignment = $xlCenter
    $excel.Rows.Item(1).VerticalAlignment = $xlTop
    $excel.Rows.Item("1:1").Font.Name = "Calibri"
    $excel.Rows.Item("1:1").Font.Size = 11
    $excel.Rows.Item("1:1").Font.Bold = $true
    $filename = "D:\Script\Reports\Status_$a.xlsx"
    if (test-path $filename ) { rm $filename }
    $wb.SaveAs($filename, $xlOpenXMLWorkbook) #save as an XML Workbook (xslx)
    $wb.Saved = $True #flag it as being saved
    $wb.Close() #close the document
    $Excel.Quit() #and the instance of Excel
    $wb = $Null #set all variables that point to Excel objects to null
    $ws = $Null #makes sure Excel deflates
    $Excel=$Null #let the air out
    I would like to use connection string to query the database and write results to EXCEL, i.e.
    $SQL_Statement = "SELECT ..."
    $conn = New-Object System.Data.SqlClient.SqlConnection
    $conn.ConnectionString = "Server=10.10.10.10;Initial Catalog=mydatabase;User Id=$username;Password=$password;"
    $conn.Open()
    $cmd = New-Object System.Data.SqlClient.SqlCommand($SQL_Statement,$conn)
    do{
    try{
    $rdr = $cmd.ExecuteReader()
    while ($rdr.read()){
    $sql_output += ,@($rdr.GetValue(0), $rdr.GetValue(1))
    $transactionComplete = $true
    catch{
    $transactionComplete = $false
    }until ($transactionComplete)
    $conn.Close()
    How would I read the columns and data for $sql_output into an EXCEL worksheet. Where do I find these tutorials?

    Hi Q.P.Waverly,
    If you mean to export the data in $sql_output to excel document, please try to format the output with psobject:
    $sql_output=@()
    do{
    try{
    $rdr = $cmd.ExecuteReader()
    while ($rdr.read()){
    $sql_output+=New-Object PSObject -Property @{data1 = $rdr.GetValue(0);data2 =$rdr.GetValue(1)}
    $transactionComplete = $true
    catch{
    $transactionComplete = $false
    }until ($transactionComplete)
    $conn.Close()
    Then please try to use the cmdlet "Export-Csv" to export the data to excel like:
    $sql_output | Export-Csv d:\data.csv
    Or you can export to worksheet like:
    $excel = New-Object -ComObject Excel.Application
    $excel.Visible = $true
    $workbook = $excel.Workbooks.Add()
    $sheet = $workbook.ActiveSheet
    $counter = 0
    $sql_output | ForEach-Object {
    $counter++
    $sheet.cells.Item($counter,1) = $_.data1$sheet.cells.Item($counter,2) = $_.data2}
    Refer to:
    PowerShell and Excel: Fast, Safe, and Reliable
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

Maybe you are looking for

  • Error in Check DB after RESTORE and RECOVER

    Hi Team, System was partially restored and recovered due hardware failure. We had 3 file systems that had to be restored and in one of them we has "/oracle/BWP/sapdata8/temp_2/temp.data2" data file. After the restore and recovery , the system was up.

  • Map Thinkpad Mouse Buttons to Keyboard Key

    Peace all! Does anyone know of a way to map the thinkpad mouse buttons to a normal keyboard key? I am unable to identify any mappable keycode using xev. Is it hardwired or something? ButtonPress event, serial 34, synthetic NO, window 0x4600001,     r

  • My icloud storage says I have plenty of space left, I keep getting a message that says not enough storage space left.

    My Icloud storage says I have plenty of space left, but I keep getting a message that says there is not enough storage left. Please help

  • Multiple Network ?

    Hi, How can I run more then one network using Airport Express at the same time. Would like to use iphone 4 with 802.11n 2.5Ghz, MacBook Pro on 802.11n 5Ghz and a Tivo and PC at the normal 802.11g Is this possible ? Profile?? Only runs the Active and

  • Playlist questions on

    I'm not really sure how the playlist thing works, so I was wondering if someone could help me. . I can't figure out how to create a playlist on the player, how is this done? 2. Is it possible to put Windows Media playlists on my player? If so, how? 3