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
source code for how to login a vb.net application ?
Which namespace are used for accessing the data?
Explain how the .net framework performs automatic memory management.
What is branching logic control in VB.NET?
What is the source code for display the picture in button click event?
What is difference between import system.data.sqlclient,system.data.oledb?
What is the purpose of an Assembly?
Can you please explain the difference between dispose and finalize()?
Explain strong name in .net assembly?
i am attending to US consulate i kept my projects on vb.net ,please help me what questions will be ask on vb.net in us consulate
What is different between web.config and machine.config and where it will be ?
What is an assembly and its use?
Tell us how many languages are supported by .net?
What is the differnce between managed code and unmanaged code?
List the types of authentication?