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 redim keyword and its use?
How to view an assembly?
Explain how to store decimal data in .net?
What is the purpose of an Assembly?
What is DLL HELL in VB.NET
What is normal jit?
What are jagged arrays ?
Explain public assembly?
Can you please explain the difference between vb and vb.net?
What are the advantages of vb.net and c#?
How can we remove handlers at run time?
Explain clr?
What is vb.net used for?
What are the different variables in vb.net?
Define cls?