adspace
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
How to send xml file on server using http protocol?
Explain how can we remove handlers at run time?
What is option strict?
What is early binding?
Explain the difference between system.string and system.stringbuilder classes?
Explain an assembly?
Explain the difference between datatable and dataset?
What is the use of assembly?
How to retrieve images in sql server database through vb.net?
How can I extract the formated word(bold,italic,underline,font,color etc) from the msword file.?
What are the features of c# which are not present in vb.net?
How to store images in sql server database through vb.net?