How to Insert a TextBox value in to Sql database using
VB.Net coding?
Answer Posted / deepmala soni
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim ra as Integer
'integer holds the number of records inserted
myConnection = New SqlConnection
("server=localhost;uid=sa;pwd=;database=Hospital")
'you need to provide password for sql server
myConnection.Open()
mycommand = New SqlCommand("INSERT INTO Patient
(ID,Name,address,DateofBirth,Gender,Phone,Emergencycontact,D
ateofRegistration) VALUES('" + lblid.Text + "','" +
txtname.Text + "','" + rtxtaddress.Text + "','" +
DateTimePicker1.Text + "','" + cmbgender.Text + "','" +
txtphone.Text + "','" + txtemcon.Text + "','" +
txtdoreg.Text + "')", mycon)ra=myCommand.ExecuteNonQuery()
MessageBox.Show("New Row Inserted" & ra)
myConnection.Close()
| Is This Answer Correct ? | 32 Yes | 23 No |
Post New Answer View All Answers
What is redim keyword?
How to connect crystal report in vb.net ?
Explain what observations between vb.net and vc#.net?
Thank you for replying to my Question regarding Barcodes in VB.net. My next question is that how to use Barcode Fonts in VB.net I need a small code to Generate Barcodes in VB.net from a string of Values. This is the only problem i am left with in my project. Any body can help me please.
Tell me how many .net languages can a single .net dll contain?
What is visual basic.net culture?
How would you implement inheritance using vb.net?
Explain about jagged arrarys ?
Explain code security?
What are the difference between dispose(), close(), exit(), end()?
What are option strict and option explicit?
Explain the observations between vb.net and vc#.net?
Explain convert.tostrin?
Explain the use of console application?
What is global assembly cache (gac)?