I have the decalaration form in which i have to dynamically generate with name and other details for users.how do i fetch the details from MS SQL database and get the pdf done for each user
Loading
I have the decalaration form in which i have to dynamically generate with name and other details for users.how do i fetch the details from MS SQL database and get the pdf done for each user
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mohamed Azarudeen ZRank #297 · 8.5K reputationPosted May 10, 2023, 7:03 AM EDT
To dynamically generate a declaration form with user details and fetch the details from a Microsoft SQL Server database, you can follow the steps below:
Note that the specifics of implementing this solution will depend on your application's architecture and requirements, as well as your programming language and tool choices. However, the above steps should provide a general framework for achieving your goal of dynamically generating declaration forms with user details from a Microsoft SQL Server database.
Amit MohantyRank #112 · 20K reputationPosted May 10, 2023, 7:11 AM EDT
Check the example, modify it to your specific requirements.
import pyodbc from reportlab.pdfgen import canvas # Connect to MS SQL database conn = pyodbc.connect("Driver={SQL Server};Server=myServerAddress;Database=myDatabase;Uid=myUsername;Pwd=myPassword;") # Fetch user details from database cursor = conn.cursor() cursor.execute("SELECT * FROM users WHERE condition='value'") users = cursor.fetchall() # Generate declaration form for each user for user in users: # Create PDF document pdf_file_name = f"{user['name']}_declaration.pdf" # Unique file name for each user pdf = canvas.Canvas(pdf_file_name) # Generate declaration form pdf.drawString(100, 750, f"Name: {user['name']}") pdf.drawString(100, 700, f"Address: {user['address']}") # Add more details as needed # Save PDF document pdf.save() # Close database connection conn.close()swetha Arumugam36 reputationPosted May 11, 2023, 1:49 AM EDT
I want the code in Php between. also onclick button it has to generate pdf file for each user with data from Ms SQL database
Kisorjan JakathiswaranRank #1,688 · 903 reputationPosted Jun 23, 2023, 2:28 AM EDT
Check out this:
https://www.etutorialspoint.com/index.php/260-how-to-fetch-data-from-database-in-php-and-display-in-pdf