Results 1 to 3 of 3

Thread: Command

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    192

    Command

    VB 6

    Private Sub Command2_Click()
    Dim sql As String
    Dim admPassword As String

    sql = "SELECT AdmPassword FROM parametri"
    rsProdaja.Open sql, cnProdaja, adOpenForwardOnly, adLockReadOnly

    If rsProdaja.RecordCount > 0 Then
    admPassword = rsProdaja.Fields("AdmPassword").Value
    rsProdaja.Close
    If Text5.Text = admPassword Then
    Frame1.Enabled = True
    Frame2.Enabled = True
    Else
    MsgBox "Neispravna lozinka!", vbInformation, App.Title
    End If
    Text5.Text = ""
    End If
    End Sub
    ------------------------------------------------------------------------
    I converted to vb2005 like this :
    Is this good?

    Private Sub Command2_Click()
    Dim sql As String
    Dim admPassword As String

    sql = "SELECT AdmPassword FROM parametri"
    rsProdaja.Open(sql, cnProdaja, adOpenForwardOnly, adLockReadOnly)
    Dim dr2 As System.Data.SqlServerCe.SqlCeDataReader

    If dr2.Read > 0 Then
    admPassword = dr2("AdmPassword")
    dr2.Close()
    If TextBox1.Text = admPassword Then
    Groupbox1.Enabled = True
    Groupbox2.Enabled = True
    Else
    MsgBox("Neispravna lozinka!", vbInformation, App.Title)
    End If
    TextBox1.Text = ""
    End If
    End Sub

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Command

    Hi,
    Does that code work? - I would guess not.
    based on my last answer in another thread

    Code:
    Dim cn As System.Data.SqlServerCe.SqlCeConnection
    Dim cmd As System.Data.SqlServerCe.SqlCeCommand
    Dim dtr As System.Data.SqlServerCe.SqlCeDataReader
    Dim sql As String
    Dim admPassword As String = ""
    
    cn.connection = "Data Source=\My Documents\mydb.sdf"
    Try
    cn.open
    catch ex as exception
    messagebox.show(ex.tostring)
    end try
    cmd = New SqlCeCommand("SELECT AdmPassword FROM parametri", cn)
    dtr = cmd.ExecuteReader()
    
      While dtr.Read()
          admPassword = dr2("AdmPassword")
        End While
    
    dtr.close
    
    If TextBox1.Text = admPassword Then
    Groupbox1.Enabled = True
    Groupbox2.Enabled = True
    Else
    MsgBox("Neispravna lozinka!", vbInformation, App.Title)
    End If
    would be closer.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    192

    Resolved Re: Command

    Thanks it work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width