Connection VB to SQL Express for Multi-User

yuzhen

Member
Joined
May 13, 2009
Messages
12
Programming Experience
Beginner
Hi, below is the codes i have for my program but it jus cant connected to the host PC.

I am running 2PC, 1 is the Host another 1 is the Client and database table is create in sql too.

- Shld I be using window authentication or sql server authentication?

- the error i hav is "login failed for user "IFCDU1-WS23\user" (It's on window authentication where dere is no password.)

- do I nid another server to run btwn host and client if my database table is alr created in sql?

what should i do? nid help badly

**********************************************************

Imports System.Data
Imports System.Data.SqlClient

Public Class NewRecord

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

Dim connAdd As New SqlConnection _
("Data Source=152.226.152.99\SQLEXPRESS,1433;" + "Initial Catalog=PatientInfo;" + "User ID=IFCDU1-WS23\user;" + "Password=;")

'Dim connAdd As New SqlConnection _
'("Server=IFCDU1-WS23\SQLEXPRESS; Database=PatientInfo; User ID=IFCDU1-WS23\user; Password=; Trusted_Connection=False;")
Dim mySQL As String

Try
connAdd.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error Open", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

mySQL = "insert into pInfo (patientIC, patientName, gender, address, contactNo, condition) values ('" & Trim(txtPIc.Text) & "','" & Trim(txtPName.Text) & "', '" & Trim(cbGender.Text) & "','" & Trim(txtAddress.Text) & "','" & Trim(txtContact.Text) & "','" & Trim(txtCondition.Text) & "' ) "

Dim cmdAdd As New SqlCommand(mySQL, connAdd)

Try
cmdAdd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error Query", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

Dim Response As New Response()
Response.Show()
Me.Hide()

End Sub
End Class

**********************************************************

Best Regards,
Dawn.Lee :confused:
 
I have solved the problem already. Its due to the administrator login. manage to get the password and run as administrator so it works. Before getting the administrator p/w, I have already done the procedures to enable remote connection =)

Thanks.
Best Regards,
Dawn.Lee :)
 
Back
Top