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 + "')", 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
Explain the difference between system.string and system.stringbuilder classes?
How to send xml file on server using http protocol?
Explain the difference between datatable and dataset?
What is early binding?
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.?
Explain how can we remove handlers at run time?
What are the features of c# which are not present in vb.net?
How to store images in sql server database through vb.net?
What is option strict?
Explain an assembly?
What is the use of assembly?