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 + "')", 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


Please Help Members By Posting Answers For Below Questions

How to send xml file on server using http protocol?

1077


Explain how can we remove handlers at run time?

1077


What is option strict?

1214


What is early binding?

1016


Explain the difference between system.string and system.stringbuilder classes?

1082


Explain an assembly?

1059


Explain the difference between datatable and dataset?

1423


What is the use of assembly?

1081


How to retrieve images in sql server database through vb.net?

1043


How can I extract the formated word(bold,italic,underline,font,color etc) from the msword file.?

1108


What are the features of c# which are not present in vb.net?

1185


How to store images in sql server database through vb.net?

1025