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 the significance of delegates?
What are the different types of Lock available in Visual Basic?
What is the importance of a Button control?
What is globalization?
What are the differences between server-side and client-side code?
What is enumerator?
what is the need for dynamic controls in vb.net? i would like to know for what purpose should we create the controls dynamically? please give the answer in simple words.
What is a stream in vb.net?
What are jagged arrarys ?
What is the difference between manifest and metadata?
What is non_deterministic finalization?
What is branching logic control in VB.NET?
What is normal jit?
List the different types of assembly?
What is static member?