adspace


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


Please Help Members By Posting Answers For Below Questions

How to send xml file on server using http protocol?

1077


Explain how can we remove handlers at run time?

1077


How to retrieve images in sql server database through vb.net?

1043


What are the features of c# which are not present in vb.net?

1185


What is the use of assembly?

1081


Explain an assembly?

1059


What is option strict?

1214


What is early binding?

1016


How can I extract the formated word(bold,italic,underline,font,color etc) from the msword file.?

1108


How to store images in sql server database through vb.net?

1025


Explain the difference between datatable and dataset?

1423


Explain the difference between system.string and system.stringbuilder classes?

1082