TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aktham Mahmoud
NA
720
38.1k
Store Qrcoder image in data base
Jul 19 2020 8:06 AM
Greeting all
I viewed many examples about generat Qrcoder and no problem with with me; a code below working correctly:
private
void
GenerteSign()
{
string
FName = txtFisrtName.Text;
string
LName = txtLastName.Text;
string
Codearray = FName +
"\n"
+ LName;
QRCodeGenerator qrGenerator =
new
QRCodeGenerator();
QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(Codearray, QRCodeGenerator.ECCLevel.Q);
System.Web.UI.WebControls.Image imgBarCode =
new
System.Web.UI.WebControls.Image();
imgBarCode.Height = 150;
imgBarCode.Width = 150;
using
(Bitmap bitMap = qrCode.GetGraphic(20))
{
using
(MemoryStream ms =
new
MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte
[] byteImage = ms.ToArray();
imgBarCode.ImageUrl =
"data:image/png;base64,"
+ Convert.ToBase64String(byteImage);
}
//End Using Memorystream
//==Implement Qrcoder parameter to PlaceHolder Control
PlH_Qr.Controls.Add(imgBarCode);
//==End Implement Qrcoder
}
//End Using Bitmap
}
So a last code we using Placholder control to catch Qrcoder value, some example use Image control (that's depends what you like).
My question:
How to store Plachoder value in data base, as I see placehoder just has method (
.Controls.Add).
is that possible or not.
Table T-SQL Code:
CREATE
TABLE
[dbo].[
Forum_RUsers
] (
[Id]
INT
IDENTITY (1, 1)
NOT
NULL
,
[Frm_Name] NVARCHAR (50)
NULL
,
[Frm_LName] NVARCHAR (50)
NULL
,
[Frm_QRSign] VARBINARY (
MAX
)
NULL
,
PRIMARY
KEY
CLUSTERED ([Id]
ASC
)
);
Secondly:
I see that example use Qrcoder implemented in (Save Button),see refernce:
https://www.aspforums.net/Threads/208874/Generate-QR-code-Image-and-save-in-Database-using-C-and-VBnet-in-ASPNet/
Actually, that's possible to follow last example, but I need to show Qrcoder firstly and in next step let user click on save form.
Some suggestion in many examples said "why to use store Qrcoder in D.B , store it in image folder, that's right; But for for security level keep it in D.B".
Save Button code:
protected
void
SendFrm(
object
sender, EventArgs e)
{
try
{
string
CONSTRFrM = @
"Data Source=(local)\SQLEXPRESS;AttachDbFilename=|DataDirectory|\aspnet-FrmREg.mdf;Integrated Security=True"
;
using
(SqlConnection con =
new
SqlConnection(CONSTRFrM))
{
SqlCommand cmd =
new
SqlCommand(
"INSERT INTO Forum_RUsers(Frm_Name,Frm_LName,Frm_QRSign) VALUES (@Frm_Name,@Frm_LName,@Frm_QRSign)"
, con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
cmd.Parameters.AddWithValue(
"@Frm_Name"
, txtFisrtName.Text.Trim());
cmd.Parameters.AddWithValue(
"@Frm_LName"
, txtLastName.Text.Trim());
cmd.Parameters.AddWithValue(
"@Frm_QRSign"
,
"Not Implemented Yet"
);
cmd.ExecuteNonQuery();
lblMessage.Text =
"Your Form submitted successfully"
;
lblMessage.ForeColor = System.Drawing.Color.Green;
}
}
}
catch
(Exception)
{
lblMessage.Text =
"Your record not submitted"
;
lblMessage.ForeColor = System.Drawing.Color.Red;
}
}
What the solution to reuse
GenerteSign() method to imlement in save code;
thanks
Reply
Answers (
1
)
ASP.NET Listening Port
I want to send datatable value from one page to 2nd in asp.net c#