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
Explain jagged array in vb.net?
What is the use of internal keyword?
Explain convert.tostring and i.tostring method?
Write program in VB.Net with SQL Server and Crystal Reports to develop a small windows application to add,edit,save, search and print Employee Information and send sourcecode as zip file. empcode : .............. empname : .............. dateofjoin : dd/mm/yyyy dateofbirth : dd/mm/yyyy TableName: EmpMaster EmpCode EmpName DOB DOJ TableName: EmpDocs EmpCode DocNo DocName ExpDate
What is the feature which is common to all .net languages?
Explain what observations between vb.net and vc#.net?
Explain public assembly?
Can you please explain the difference between dispose and finalize()?
What is the difference between system.applicationexception class and system.systemexception?
What is the top .net class that everything is derived from?
What is the importance of a Button control?
What are the technology areas that microsoft.net contains?
What are the different types of a stream?
What are the features present in vb 2005?
When do you use virutal keyword?