Introduction
As you all know, these days, barcodes and QR codes are so popular in the industry.QR (Quick Response) Code is a type of Matrix Bar code as its name defines quick response. Due to this, it became so popular for its fast readability and greater storage capacity when compared to standard barcodes. The industries include product tracking, item identification, and asset management, which mainly uses the QR code. because a single QR code can hold all the product-related information. and when you read the QR code, it gives you all the related information stored in it instantly.
Now in this article, we see how we can Generate the QR Code in ours.net Application and save it to the database for further use.
This example shows you how we can generate a QR sticker for product or asset-tracking applications. in this, I give a range to generate the QR codes for that, first select the Asset from and to the range and then click the button Generate QR code. I assume that u know a little bit about the c# so that I skip the small things.

For this, you need to add 2 more namespaces.
using System.Text;
using QRCoder;
On the button, click event call a function and add the below code into the function. what this function does is retrieve all the necessary information from the database corresponding to a particular asset in the selected range, and using a for loop, we generate a QR code save the QR code to the database, and then print the stickers so that we paste the stickers into the asset or product whatever your requirement.
con = Mydatabase.MyDB.getConnection();
string SQL = "select id, ast_id, MachineNo, invno, convert(nvarchar(11), ae.vchdate) invdate from asset";
SqlCommand command = new SqlCommand(SQL, con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
string astID = dt.Rows[i]["id"].ToString();
string astCode = dt.Rows[i]["ast_id"].ToString();
string loc = dt.Rows[i]["ast_loc"].ToString();
string serialNo = dt.Rows[i]["MachineNo"].ToString();
string invno = dt.Rows[i]["invno"].ToString();
string invdate = dt.Rows[i]["invdate"].ToString();
StringBuilder bcode1 = new StringBuilder("Ast Code: " + astCode + Environment.NewLine +
"S.No: " + serialNo + Environment.NewLine +
"Inv No: " + invno + Environment.NewLine +
"Inv Date: " + invdate);
saveToDatabase(bcode1, Convert.ToInt32(astID));
}
In the above function, we make a string using StringBuilder for which we can generate the QR code and call the function saveToDatabase that generates the code and save it into the database. first let's create a table that stores the information like the unique ID of the row, the QR code held in the BRCD column, and the image of the QR code stored in the IMG column of the image datatype. we see how we can convert the QRcode to an image in the below function and the PID holds your product ID for which you create the QR code.



TamilzhazhaganPosted Feb 23, 2024, 5:09 AM
Hi Abhishek could you please post the generate QR report code here
Kunal GuptaPosted Jun 17, 2022, 11:56 AM
I have a problem some i am trying to show some values save in my database in QR Code in pdf that consist of data of values taken from database. In addition to it i want to fetch some values from database in QR Code and adjust in that pdf.
Fabrizio LeonciniPosted Mar 15, 2022, 3:14 PM
Good morning congratulations for your work, I can't understand how your tutorial works, please don't have the code to make available?Thanks a lot and congratulations Fabrizio from Italy
Oliver CastroPosted Feb 16, 2021, 8:49 AM
The type name 'QRCode' does not exist in the type 'QRCodeGenerator' How to fix this? thank you!
mohaammed talhaPosted Feb 4, 2021, 10:03 AM
I Need Design Of The Form