What's new

Help C# Patulong about sql server

Xlayer

Forum Guru
Elite
Joined
Mar 29, 2017
Posts
2,851
Reaction
1,389
Points
1,078
Gumagawa kase ako ng system na " Student attendance management gamit ang qr code "
So ganito ang gusto kong mangyari.

Gumawa ako ng dalawang table sa isang database for Primary key and foreign key table .
Untitled.png


then ang db.sample1 nilagyan ko ng data

Untitled.png

then sa db.sample2 ni relationship ko sya sa sample1 na ID , para kung anong meron na data lang yung nasa sample1 ay yung lang ang e rerecord ng QR code if wala dun sa sample1 na data , di sya e rerecord

ex: nag generate ako ng qr code na may data na 123 or 1234 . bali yan lang ang e rerecord ng qr code system ko pero kung 12345 . di sya ererecord

Untitled.png

So ganito ang gusto ko mangyari , pag nag scan ako ng QR code na may data na ID ay 123 or 1234 , Mag automatic save sya sa database ( nagawa ko na pero ID lang ang narerecord ) pero ang gusto ko ay pag na scan yung ID na related sa data ng sample1 ay automatic rin ma rerecord yung " Name" na tugma sa id .
Posible kaya yun ?
may paraan ba para magawa yun?

Salamat sa tutulong
 

Attachments

Last edited:
On qr scan. using QR will produce ID using the ID create a query to search the table for matches.
ex.
QR Code Scan - Produce ID
Use ID to query the name of the said ID.
get the Values transfer then to a String array/data model.
get the Values to be used ID, Name.
save using query.

Then done.
 
On qr scan. using QR will produce ID using the ID create a query to search the table for matches.
ex.
QR Code Scan - Produce ID
Use ID to query the name of the said ID.
get the Values transfer then to a String array/data model.
get the Values to be used ID, Name.
save using query.

Then done.
Wal ka bang sample jan paps kung pano ? kakalito e
 
Medyo nakakalito yung tables sir. Ano ba purpose ng tables mo? Pangalan mo para madali maintindihan.
Ano yung Name column sa sample1 table?
Ano yung Name column sa sample2 table?

Hindi ko rin alam kung tama ang assumptions ko:
  • Yung sample1 table is Classes table and the name column is the name of the class.
  • Yung sample2 table is ClassAttendance table and the name column is the name ng student na aatend ng class (o yung name ng class?)

Another question, kapag nag-scan ng QR, ano ang data na nababasa from the QR code. Class ID and Student ID lang ba o kasama na pati values ng mga names?

Pero eto try mo sir:

INSERT INTO dbo.sample2(Id, Name)
SELECT <Sample2TableIdValueFromQRCode>, '<Sample2TableNameValueFromQRCode>'
WHERE EXISTS (SELECT Id FROM dbo.sample1 WHERE Id = <Sample1TableIdFromQRCode>)

Basically mag-iinsert sya sa sample2 kapag may nag-eexists na corresponding id sa sample1.
 
Last edited:

Similar threads

Back
Top