Hello guys,

This is the code i wrote

package com.android.DBConnection;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import java.sql.*;

public class DBConn extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button button =
(Button)findViewById(R.id.btnCheckDBConnection);
        button.setOnClickListener(mCheckDBConnectionListener);
    }

    private OnClickListener mCheckDBConnectionListener = new
OnClickListener()
    {
        public void onClick(View v)
        {
            // To send a result, simply call setResult() before your
            setResult(RESULT_OK, (new
Intent()).setAction("DBConnection!"));
            AlertDialog.Builder Aldg = new
AlertDialog.Builder(DBConn.this);
            try{
                Aldg.setTitle("Check DB Connection");
 
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                Connection DBConnSQL =
DriverManager.getConnection("jdbc:sqlserver://kcp-tech-015\\SQLEXPRESS:
1433;DatabaseName=CafetriaManagement","sa","sa");

                if (DBConnSQL==null)
                        Aldg.setMessage("Not Connected");
                else
                        Aldg.setMessage("Connected");

                        //Statement stmt=
DBConnSQL.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                            //ResultSet.CONCUR_READ_ONLY)   ;
                        //ResultSet rst = stmt.executeQuery("SELECT COUNT(*)
FROM SALE");
                        //while (rst.next())
                        //{
                        //      Aldg.setMessage(rst.getString(1));
                        //}

            } catch (Exception ex) {
                Aldg.setMessage("Error: " + ex);
            } finally {
                Aldg.show();
            }
        }
    };
}

On Nov 10, 10:25 pm, Michael <[EMAIL PROTECTED]> wrote:
> Maybe you could provide some sample code so we can figure out what
> you're doing?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to