Aurito's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
18 (0.04 per day)
Joined:
05-February 12
Profile Views:
417
Last Active:
User is offline Aug 12 2012 07:38 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   Aurito has not set their status

Posts I've Made

  1. In Topic: ListBox Questions

    Posted 12 Aug 2012

    How should I settext at the label when i select one of the listbox object where i hardcode the quantity in the datastorage than i when i select the object in the jlist i want it to display the hardcoded quantity in the label. Can show me some reference because i cannot find a related example. Thanks
  2. In Topic: error in storing into database

    Posted 25 Jul 2012

    Here is the code from my main form.
    <code>
    Imports System.Data
    Imports System.Data.SqlServerCe
    
    Public Class LoginPage
        Dim ssceconn As New SqlCeConnection("Data Source = \My Documents\test.sdf")
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If System.IO.File.Exists("\My Documents\test.sdf") Then
                System.IO.File.Delete("\My Documents\test.sdf")
            End If
            Dim engine As New SqlCeEngine("Data Source = \My Documents\test.sdf")
            engine.CreateDatabase()
    
            Dim sqlCreateTable As SqlCeCommand = ssceconn.CreateCommand()
            sqlCreateTable.CommandText = _
            "CREATE TABLE Client(username nvarchar(20), password nvarchar(20))"
    
            ssceconn.Open()
            sqlCreateTable.ExecuteNonQuery()
            ssceconn.Close()
    
            Dim sqlCreateTable1 As SqlCeCommand = ssceconn.CreateCommand()
            sqlCreateTable1.CommandText = _
            "CREATE TABLE Client_Details(datefrom nvarchar(10), datetill nvarchar(10), premium integer, salutation nvarchar(5), f_name nvarchar(20), l_name nvarchar(20), gender nvarchar(6), NRIC nvarchar(10), DOB nvarchar(10), race nvarchar(10), marital_status nvarchar(15), occupation nvarchar(30), address nvarchar(100), home integer, hp integer, off1 integer, email nvarchar(60))"
    
            ssceconn.Open()
            sqlCreateTable1.ExecuteNonQuery()
            ssceconn.Close()
    
            Dim sqlCreateTable2 As SqlCeCommand = ssceconn.CreateCommand()
            sqlCreateTable2.CommandText = _
            "CREATE TABLE Home_Details(address nvarchar(60), postal integer, typeOfProp nvarchar(20), valuables nvarchar(20), material nvarchar(20), occOfHome nvarchar(20), additional nvarchar(20))"
    
            ssceconn.Open()
            sqlCreateTable2.ExecuteNonQuery()
            ssceconn.Close()
    
        End Sub
    
        Private Sub btnReg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReg.Click
            RegistrationPage.Show()
            Me.Hide()
        End Sub
    
        Private Sub TxtPw_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtPw.TextChanged
            TxtPw.PasswordChar = "*"
        End Sub
    
        Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
            btnLogin.Enabled = False
    
            Dim selectCommand As SqlCeCommand = ssceconn.CreateCommand()
    
            selectCommand.CommandText = "SELECT * FROM Client Where username = '" & TxtUser.Text & "'"
    
            ssceconn.Open()
            Dim myReader As SqlCeDataReader = selectCommand.ExecuteReader
    
            While myReader.Read()
                If (TxtPw.Text = myReader("password")) Then
                    MsgBox(TxtUser.Text)
                    MsgBox(" has logged in!")
                ElseIf (TxtPw.Text = myReader("password")) Then
                    MsgBox("Invalid account")
                    MsgBox("Please enter your password or username")
                End If
            End While
    
            myReader.Close()
    
            If ssceconn.State = ConnectionState.Open Then
                ssceconn.Close()
            End If
    
            btnLogin.Enabled = True
    
            MenuPage.Show()
            Me.Hide()
    
        End Sub
    End Class
    
    </code>
    


    I want to store the info into my database but it came up the error that I listed above. And can i know how to restrict user to getting to another form if the login info they type does not / haven created in the database.
  3. In Topic: error in storing into database

    Posted 25 Jul 2012

    This is the attachment.
  4. In Topic: How should add to the actionlistener

    Posted 14 Feb 2012

    View Postmacosxnerd101, on 14 February 2012 - 06:32 AM, said:

    Take a look at using a ComboBoxModel and modify its contents.

    Also, pbl suggesting you implement the interface rather than using anonymous inner classes for stylistic reasons.
    class MyFrame extends JFrame implements ActionListener{
    
         private JComboBox months, days;
    
         MyFrame(){
            months = new JComboBox(new String[]{"m1","m2", ... , "m12"});
            days = new JComboBox(new String[]{"1","2","3",...,"30"});
    
            months.addActionListener(this):
            days.addActionListener(this);
         
         }
    
         public void actionPerformed(ActionEvent e){
             //hande the actions for months and days here
         }
      
    }
    
    


    Also, if you have variables named like this, it is begging for an array.

    Quote

    lb3, lb4, lb5, lb6, lb7, lb8, lb9, lb10


    Thanks for the guide
  5. In Topic: How should add to the actionlistener

    Posted 14 Feb 2012

    View Postpbl, on 12 February 2012 - 06:55 PM, said:

    Anonymous actionListener classes are not the good approach if you want to synchronized multiple JComboBox
    better to have your main class to implement ActionListener and synchronize all your JCombobox in a single actionPerformed() method


    Can you explain it again ? Thanks

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Comments

Aurito has no profile comments yet. Why not say hello?