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
Name and explain some of the exclusive features which are present in vb?
What are all the parts of .net framework?
what is difference between namespace and assembly?
Explain what observations between vb.net and vc#.net?
What is an assembly and its use?
what is the advantage of option strict on?
Write a VB.Net console program to check whether a number is perfect or not.
What do you mean by Redim in VB.NET?
i have two class that contain's two methods as same name in derived class i have to call these two methods what will happen at run time ?
How to connect crystal report in vb.net ?
Explain convert.tostring and i.tostring method?
Explain the difference between value and reference types?
Before in my vb app I would just load the icons from dll. How can I load the icons provided by .net dynamically?
What are the shadow variables?
Explain about globalization?