Shown in the above form is a first name, last name and age text boxes named txtFName, txtLName and txtAge respectively. lastly, is the update button named BtnUpdate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Source Code ~> Vbasic 2010 vs Sql Server 2005
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Imports System.Data
Imports System.Data.SqlClient
Public Class frm_main ' Class Begins Here
' Declare a new
Sql_client_connection = SqlConn
' Sql_Command =
SqlComm AND
'
Sql_Connection_String
Dim SqlConn
As New
SqlClient.SqlConnection
Dim SqlComm
As New SqlCommand
' Data Source =
Server Name; Initial Catalog = DataBase Name
Dim
SqlConnString = "Data Source=DOUBRA-PC;Initial
Catalog= clems;Integrated Security=True "
Private Sub frm_main_Load(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
MyBase.Load
SqlConn.ConnectionString =
SqlConnString
SqlConn.Open()
End Sub
Private Sub BtnUpdate_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
BtnUpdate.Click
SqlComm.CommandText = "Insert into Employee values(' " &
txtFName.Text & " ', ' " &
txtLName.Text & " ', ' " &
txtAge.Text & " ')"
SqlComm.CommandType = CommandType.Text
SqlComm.Connection = SqlConn
SqlComm.ExecuteNonQuery()
End Sub
End Class ' Class Ends Here
Source code screen shot
Source code screen shot
~~~~~~~~~~~~~~~~
No comments:
Post a Comment