How to Insert a TextBox value in to Sql database using
VB.Net coding?
Answer Posted / dinesh
Imports System.Configuration
Imports System.Data.SqlClient
Public Class Form1
Dim objcon As SqlConnection
Dim objcmd As SqlCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
objcon.Open()
objcmd = New SqlClient.SqlCommand("insert into customer_master(First_Name,Last_Name,Address,contact_number,email_id)values('" & TextBox1.Text.Trim & "','"& TextBox2.Text.Trim &"','"& TextBox3.Text.Trim &"','" & TextBox5.Text.Trim & "','" & TextBox7.Text.Trim & "')", objcon)
Dim i As Integer = objcmd.ExecuteNonQuery()
If (i > 0) Then
MsgBox("Customer saved successfully!")
Else
MsgBox("Failed to save Customer!")
End If
objcon.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
| Is This Answer Correct ? | 8 Yes | 6 No |
Post New Answer View All Answers
What is the feature which is common to all .net languages?
What is normal jit?
How to store images in sql server database through vb.net?
Explain the difference between vb.net and c#, related to oops concepts?
What are the features of c# which are not present in vb.net?
What is the purpose of an Assembly?
What is multiple form in vb?
Explain namespace?
Explain how does the xmlserializer work?
Explain the difference between c# and vb.net?
What are nested classes?
What is the ruby interface generator?
Explain convert.tostrin?
Did vb6 support multi-threading ?
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