/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
VB with SQL newbie in need of aid. Please ~
Fra : Myrath


Dato : 09-06-01 08:54

Hi all;

I'm in need of some help. I'm trying to figure out SQL under visual basic 6,
but I'm running into some problems. I would realy appreciate any help you
could give.

I'm trying a simple thing. A form is dislayed with 2 textboxes..
tb_username, and tb_password. Lastly a button cb_ok.
When the button is pressed the program is only supposed to give a messagebox
"login succesful" or "login failed".

I have an access 2000 databasefile. C:\databasefile.mdb
This databasefile contains 1 table "userdata" with 2 columns. "Username"
(primary key) and "Password"
I have tried a lot of stuff, but I just cannot figure it out.. if any of you
could have a look at it for me please? I would be eternaly grateful.

I know this part is right... but after that.. I cannot be certain.

Thanks a million!

mvdmeij@kabelfoon.nl


Private Sub cb_ok_Click()

Dim DBFILE As Database
Set DBFILE = OpenDatabase("c:\databasefile.mdb")

end sub

** P.S. I'm Dutch.. so please keep any variable names you may use English!
Thanks!




 
 
Lars Hoffmann (09-06-2001)
Kommentar
Fra : Lars Hoffmann


Dato : 09-06-01 09:36

Myrath wrote:
>
> I know this part is right... but after that.. I cannot be certain.
>
> Thanks a million!
>
> mvdmeij@kabelfoon.nl
>
> Private Sub cb_ok_Click()
>
> Dim DBFILE As Database
> Set DBFILE = OpenDatabase("c:\databasefile.mdb")
>
> end sub

So I'll just add what you need
Of course you have selected Project -> References -> Microsoft DAO.....


Private Sub cb_login_Click()
Dim DAO_Workspace As Workspace
Dim DAO_Database As Database
Dim DAO_recordset As Recordset
Dim SQL As String


SQL = "SELECT username,password from usernames where Username='" _
& tb_username.Text & "' and password='" & tb_password.Text & "';"

Set DAO_Workspace = CreateWorkspace("", "admin", "")
Set DAO_Database = DAO_Workspace.OpenDatabase("c:\db1.mdb")
Set DAO_recordset = DAO_Database.OpenRecordset(SQL)

If DAO_recordset.BOF And DAO_recordset.EOF Then
Call MsgBox("You do not have access")
Else
Call MsgBox("Welcome!")
End If
End Sub




--
/Lars

HTML software: <http://go.to/HTMLEasyColors>
Brug venligst Re: og ikke Sv: ved svar, da beskeder
der begynder med Sv: bliver slettet fra mange servere

Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408929
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste