Imports System.Data
Imports System.Data.SqlClient
Public Class Register
Dim sqlcon As SqlConnection
Dim ds As DataSet
Dim da As SqlDataAdapter
Private Sub Register_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sqlcon = New SqlConnection("Data Source=XXXXXXXXX;Initial Catalog=DVDRent;Integrated Security=True")
If sqlcon.State = ConnectionState.Closed Then
sqlcon.Open()
End If
End Sub
Private Sub btmreturnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmreturnok.Click
Dim str As String = "INSERT INTO Employees (id,pass,fname,lname,mobi,rank) VALUES ('" & txtuserregis.Text.Trim & "','" & txtpasswordregis.Text.Trim & "','" & txtfname.Text.Trim & "','" & txtlname.Text.Trim & "','" & txtmobi.Text.Trim & "','" & ComboBoxpos.SelectedItem.Trim & "')"
Dim com As New SqlCommand(str, sqlcon)
Dim dr As SqlDataReader = com.ExecuteReader()
If dr.HasRows Then
dr.Read()
Else
MessageBox.Show("Complete")
End If
dr.Close()
End If
End Sub
End Class
Tag : .NET, Ms SQL Server 2008, VB.NET, VS 2010 (.NET 4.x)