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
Is it necessary to have SQL server installed in your computer in order to create a service based database in vb.net?
When do you use virutal keyword?
Explain how can we remove handlers at run time?
What are the differences between c# and visual basic.net?
What are the different variables in vb.net?
Explain jit?
Which classes a dll can contain?
What is the difference between convert.tostring and i.tostring method?
How do you use two datareaders at the same time in a vb.net windows application ?
What is the feature anonymous type?
How do you define a read only property in a class module?
Explain an assembly?
i am attending to US consulate i kept my projects on vb.net ,please help me what questions will be ask on vb.net in us consulate
What is internal keyword in .net framework?
Write the role of new keyword?