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 + "')", myconnection)
ra=myCommand.ExecuteNonQuery()
MessageBox.Show("New Row Inserted" & ra)
myConnection.Close()
| Is This Answer Correct ? | 46 Yes | 18 No |
Post New Answer View All Answers
What is portable executable?
How to connect crystal report in vb.net ?
Explain about Visual basic.NET culture?
what is interface and when it is used?
What is enumerator?
Name some of the features present in vb 2005?
Explain convert.tostrin?
Explain how to store decimal data in .net?
What are the technology areas that microsoft.net contains?
What is the maximum size of the textbox?
How do you use two datareaders at the same time in a vb.net windows application ?
Explain jagged array in vb.net?
Explain the use of new keyword?
What keyword is used to accept a variable number of parameter in a method?
Explain about visual basic?