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 common language specification?
Which class allows an element to be accessed using unique key?
What is redim keyword?
What is the strong name in .net assembly?
What is difference between inline and code behind?
Write a program to find all text files in a logical drive and return the count of the number of files?
What is the difference between import system.data.sqlclient and system.data.oledb?
what is interface and when it is used?
What is stack used for in vb. Net?
What is the feature anonymous type?
Explain about Visual basic.NET culture?
What are the difference between dispose(), close(), exit(), end()?
What is a static variable?
What is sealed class?
What do you mean by Redim in VB.NET?