ต้องการเขียน login file การ Login ลงเครื่อง server ตามหมายเลข IP ไม่ทราบทำอย่างไรคะ
ตอนนี้ทำได้แต่เขียนลงเครื่องที่รันคะ Code (VB.NET)
Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogin.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim rd As SqlDataReader
con.ConnectionString = "Data Source=localhost; Initial Catalog = MMS; Integrated Security= true"
' con.ConnectionString = ("user id = sa;data source = 192.168.5.24 ; persist security info = True;initial catalog = MMS ;password = ttcadmin")
cmd.Connection = con
con.Open()
cmd.CommandText = "Select Emp_id, Password from Employee where Emp_id ='" & txtUsername.Text & "'and Password = '" & txtPassword.Text & "'"
rd = cmd.ExecuteReader
If rd.HasRows Then
MessageBox.Show("Welcome to Machine Mantenance System.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information)
frmMain.user_idLogin = txtUsername.Text
frmMain.Show()
Me.Hide()
Dim sw As StreamWriter = New StreamWriter("d://log.txt", True)
sw.WriteLine(Me.txtUsername.Text & ";" & Date.Now.ToString("dd/MM/yyyy"))
sw.Close()
ElseIf txtUsername.Text = "" Or txtPassword.Text = "" Then
MessageBox.Show("Please enter username and password.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
MessageBox.Show("Please enter username and password are correct.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
con.Close()
frmMachineRecord.EmpID = txtUsername.Text
End Sub