Προς το περιεχόμενο

SQL kai * se int field


Dvs

Προτεινόμενες αναρτήσεις

Δημοσ.

Exo enan pinakai me diafora pedia.

Dino to SELECT:

Data1.RecordSource =

"SELECT DISTINCT progname.pname

FROM progname,pdetails

WHERE progname.pcode = pdetails.pcode

AND progname.pname like " & Chr(34) & prog & Chr(34) &

" AND pdetails.version like " & Chr(34) & ver & Chr(34) &

" AND protection = " & prot <---To 'protection' einai tipou integer. To prot einai i metavliti pou krataei auto pou thelei na psaxei o xrisitis.

 

An to afisei keno vazo ena * alla auto distixos den douleuei (profanos, giati einai int). Iparxei kapoios tropos na to kano na doulepsei?

[Allios tha prepei na pexo me pollapla if & select ,to opoio prospatho na apofigo:)]

Δημοσ.

Den uparxei tropos na to kaneis na doulepsei me SQL. Alla padws den nomizw oti blekeis me polla if:

 

>Data1.RecordSource = 
"SELECT DISTINCT progname.pname 
FROM progname,pdetails 
WHERE progname.pcode = pdetails.pcode 
AND progname.pname like " & Chr(34) & prog & Chr(34) & 
" AND pdetails.version like " & Chr(34) & ver & Chr(34)

if UserInsertedProtection then
    Data1.RecordSource = Data1.RecordSource & " AND protection = " & prot 
end if

Data1.open

 

Opote gia kathe optional pedio tupou integer pou borei na min exei epileksei o user, thes apla 1 if statement. Bebaia gia logous taxutitas kai optimization, einai kalutera na bazeis prwta sto sql ta statements me ta kleidia sou kai ta integer kai meta ta like statements pou einai afadasta arga.

Δημοσ.

Se aytes tis periptoseis einai sinithes na xtizetai to SQL statement dynamika meso kvdika. Tha xtizeis to statement se mia metabliti kai meta tha ekteleis to periexomeno ths metablitis

p.x.

datal.sql = sSQL

datal.open

 

Gia paradeigma an o xristis exei afhsei kenh th metavliti prot, tote den simperilambaneis to kommati 'AND protection = " & prot ' sto statement. Sthn antitheti periptosh tha to prosthetis.

 

Sthn diathesi sou gia kathe bohthia.

Δημοσ.

Apla epeidi exo 6 tetoia pedia thelo kai 6 if [den eixa skeftei na to ftiaxno dinamika alla gia kathe if na exo ftiaxei kai ena SQL statement apo prin :>] . Elega mipos iparxei tropos na to apofigo alla mallon den iparxei <img src="http://www.insomnia.gr/ubbthreads/images/graemlins/smile.gif" alt="" />

 

euxaristo

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...