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 + "')", mycon)ra=myCommand.ExecuteNonQuery()
MessageBox.Show("New Row Inserted" & ra)
myConnection.Close()
Is This Answer Correct ? | 32 Yes | 23 No |
Post New Answer View All Answers
What are jagged arrays ?
Described strong typing and weak typing?
Explain the difference between an xml "fragment" and an xml "document."
How to run a dos command in vb.net?
Explain trace in vb.net?
What does assert() method do In VB.NET
Explain internal keyword in .net framework?
What are the types of generations in garbage collector?
So you know which dll is used for microsoft .net run time?
Tell us how many languages are supported by .net?
Explain the use of serialization and deserialization?
What are the different variables in vb.net?
Explain and brief about rapid application development tool?
Can we use Vb.Net and C# language simultaneously in one .Net application?
Explain enumerator?