Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class frmChild1
Dim strConn As String
Dim Conn As OleDbConnection
Dim Com As OleDbCommand
Dim tr As OleDbTransaction
Dim sb As New StringBuilder()
Private Sub frmChild1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'GAFBizDataSet.Patient' table. You can move, or remove it, as needed.
Me.PatientTableAdapter.Fill(Me.GAFBizDataSet.Patient)
strConn = "Provider=SQLOLEDB;Data Source=illusion-f8db9b;Initial Catalog=GAFBiz;Integrated Security=True "
Conn = New OleDbConnection(strConn)
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open() "นี่คือส่วนที่มัน error"
End With
ShowData()
FormatdgvPatientList()
End Sub
Private Sub ShowData()
sb.Remove(0, sb.Length)
sb.Append("SELECT Id_Patient, Name_Patient, Lname_Patient, Bdate_Patient, Sex_Patient, Iden_Patient, Add_Patient, Phone_Patient, Tel_Patient ")
sb.Append("FROM Patient")
sb.Append("ORDER BY Id_Patient")
Dim sqlPatient As String = sb.ToString()
Dim dr As OleDbDataReader
Dim dt As DataTable
Com = New OleDbCommand()
With Com
.CommandType = CommandType.Text
.CommandText = sqlPatient
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dt = New DataTable()
dt.Load(dr)
dgvPatientList.DataSource = dt
Else
dgvPatientList.DataSource = Nothing
End If
End With
dr.Close()
End Sub
Imports MySql.Data.MySqlClient
Imports System.Data
Public Class frmLogin
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim strConnString, strSQL As String
strConnString = "Host=103.246.19.194;User Id=dyf9o11_ken; Password=289850732; Database=dyf9o11_ken; Pooling=false"
objConn.ConnectionString = strConnString
objConn.Open() [font=Verdana]Error ตรงนี้อ่ะครับ[/font]
Dim intNumRows As Integer
strSQL = "SELECT COUNT(*) FROM member WHERE Username = '" & Me.txtUsername.Text & "' AND Password = '" & Me.txtPassword.Text & "' "
objCmd = New MySqlCommand(strSQL, objConn)
intNumRows = objCmd.ExecuteScalar()
If intNumRows > 0 Then
Dim frm As New frmMain
frm._strUser = Me.txtUsername.Text
frm.LoadInfor()
frm.Show()
Me.Hide()
Else
MessageBox.Show("Username or Password Incorrect")
End If
objConn.Close()
objConn = Nothing
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
If MessageBox.Show("Exit application?", "", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Application.Exit()
End If
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
End Class
Date :
2013-02-12 21:13:44
By :
KEN
No. 10
Guest
Code
Imports MySql.Data.MySqlClient
Imports System.Data
Public Class frmLogin
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim strConnString, strSQL As String
strConnString = "Host=103.246.19.194;User Id=dyf9o11_ken; Password=289850732; Database=dyf9o11_ken; Pooling=false"
objConn.ConnectionString = strConnString
objConn.Open() มัน Error ตรงนี้อ่ะครับ
Dim intNumRows As Integer
strSQL = "SELECT COUNT(*) FROM member WHERE Username = '" & Me.txtUsername.Text & "' AND Password = '" & Me.txtPassword.Text & "' "
objCmd = New MySqlCommand(strSQL, objConn)
intNumRows = objCmd.ExecuteScalar()
If intNumRows > 0 Then
Dim frm As New frmMain
frm._strUser = Me.txtUsername.Text
frm.LoadInfor()
frm.Show()
Me.Hide()
Else
MessageBox.Show("Username or Password Incorrect")
End If
objConn.Close()
objConn = Nothing
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
If MessageBox.Show("Exit application?", "", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Application.Exit()
End If
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
End Class