|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
what's wrong with this code???
Code:
AdoNamaPelajar.Recordset.Filter = "pel_thndaftar = '" & cmbSesi.Text & "' And pel_semdaftar = '" & cmbSem.Text & "'" _ & "And pel_pengajian = '" & cmbPgjn.Text & "' And pel_ijazah = '" & cmbIjzh.Text & "' And pel_jabatan = '" & cmbJbtn.Text & "';"
__________________
teach and correct me if i am wrong... |
|
#2
|
||||
|
||||
|
are you getting a error somewhere?
the only thing i can see is a space missing here: Code:
& " And pel_pengajian = '" & cmbPgjn.Text & "' And pel_ijazah = '" & cmbIjzh.Text & "' And pel_jabatan = '" & cmbJbtn.Text & "';" hope this helps
__________________
Look! Its a ShemZilla ![]() ![]()
|
|
#3
|
||||
|
||||
|
i think the error at that place. i forgot how to write and concatenate long sql statement in vb6. do u have any example?
|
|
#4
|
||||
|
||||
|
Code:
sql = "SELECT pel_nomatriks, pel_nama, pel_alamatsm, pel_poskodsm, pel_bandarsm, pel_negarasm FROM pelajar WHERE " _ & " pel_thndaftar = '" & cmbSesi.Text & "' And pel_semdaftar = '" & cmbSem.Text & "'" _ & " And pel_pengajian = '" & cmbPgjn.Text & "' And pel_ijazah = '" & cmbIjzh.Text & "'" _ & " And pel_jabatan = '" & cmbJbtn.Text & "' ORDER BY pel_nama;" does my code above correct? i am getting error about no value given for one or more required parametes. Code:
Private Sub cmdCari_Click() On Error GoTo FINDERR sql = "SELECT pel_nomatriks, pel_nama, pel_alamatsm, pel_poskodsm, pel_bandarsm, pel_negarasm FROM pelajar WHERE " _ & " pel_thndaftar = '" & cmbSesi.Text & "' And pel_semdaftar = '" & cmbSem.Text & "'" _ & " And pel_pengajian = '" & cmbPgjn.Text & "' And pel_ijazah = '" & cmbIjzh.Text & "'" _ & " And pel_jabatan = '" & cmbJbtn.Text & "';" With rsAlamat .Close .Open sql, conAVB, adOpenStatic, adLockReadOnly, adCmdText --> error here End With Set DataGrid1.DataSource = rsAlamat DataGrid1.Refresh Exit Sub FINDERR: MsgBox Err.Description, vbOKOnly + vbExclamation, App.Title End Sub Last edited by wackyflik : May 25th, 2005 at 04:00 AM. |
|
#5
|
||||
|
||||
|
hi,
put a textbox on your form, call it txtSQL, and add this line of code, so that we can check how the sql looks Code:
sql = "SELECT pel_nomatriks, pel_nama, pel_alamatsm, pel_poskodsm, pel_bandarsm, pel_negarasm FROM pelajar WHERE " _ & " pel_thndaftar = '" & cmbSesi.Text & "' And pel_semdaftar = '" & cmbSem.Text & "'" _ & " And pel_pengajian = '" & cmbPgjn.Text & "' And pel_ijazah = '" & cmbIjzh.Text & "'" _ & " And pel_jabatan = '" & cmbJbtn.Text & "';" txtSQL.Text = sql Exit Sub With rsAlamat .Close .Open sql, conAVB, adOpenStatic, adLockReadOnly, adCmdText --> error here End With hope this helps Copy and paste the result of the sql here |
|
#6
|
||||
|
||||
|
i've changed the code to this
Code:
sql = "SELECT pel_nomatriks, pel_nama, pel_alamatsm, pel_poskodsm, pel_bandarsm, pel_negarasm FROM pelajar WHERE " & _ "pel_thndaftar = '" & cmbSesi.Text & "' And pel_semdaftar = '" & cmbSem.Text & "' " & _ "And pel_pengajian = '" & cmbPgjn.Text & "' And pel_ijazah = '" & cmbIjzh.Text & "' " & _ "And pel_jabatan = '" & cmbJbtn.Text & "';" and the result is like this Code:
SELECT pel_nomatriks, pel_nama, pel_alamatsm, pel_poskodsm, pel_bandarsm, pel_negarasm FROM pelajar WHERE pel_thndaftar = '2004/2005' And pel_semdaftar = '1' And pel_pengajian = 'Kursus & Disertasi' And pel_ijazah = 'Doktor Falsafah' And pel_jabatan = 'Fiqh dan Usul'; if i disable the debug code,i still keep getting this error. no value given for one or more required parametes. |
|
#7
|
||||
|
||||
|
ok, your sql looks fine
change this Code:
.Open sql, conAVB, adOpenStatic, adLockReadOnly, adCmdText --> error here to .Open sql, conAVB if this does not work, paste the result of the sql into access, or the query analyzer, depending on with db you are using, and see if it works there. |
|
#8
|
||||
|
||||
|
still keep getting error.
|
|
#9
|
||||
|
||||
|
did a give a error in access?
what db are you using? I think you are trying to select a field that is not in the table, just make sure all field names in the sql query is correct. |
|
#10
|
||||
|
||||
|
what happen if every fields in the pelajar table being named? and if in pelajar table has field named pel_tahundaftar, and there is another field in keputusan table also has the same named? i have checked database and figured out this duplication.
|
|
#11
|
||||
|
||||
|
do you want to select from 2 tables?
you are only selecting form pelajar in this query |
|
#12
|
||||
|
||||
|
ok, it's done. i just changed field named at the Keputusan table and then it works. i had faced this situation before when i develop my online system using ASP. thanks for ur help and time!
|
|
#13
|
||||
|
||||
|
no problem, glad its working now
![]() |