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 globalization?
What is code access security?
List the different types of assembly?
Which class allows an element to be accessed using unique key?
What is the difference between a "jagged array" and multidimensional array" ?can anyone show me it practically ?
What is difference between inline and code behind?
difference between control and component more than one differences
Explain the difference between namespace and assembly?
Explain trace in vb.net?
Explain manifest?
Explain cts?
Can you please explain the difference between c# and vb.net?
What is the differnce between managed code and unmanaged code?
Is it necessary to have SQL server installed in your computer in order to create a service based database in vb.net?
what is intermediate language?