Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
yuzhen
Starting Member
2 Posts |
Posted - 2009-05-13 : 00:25:23
|
| 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.DataImports System.Data.SqlClientPublic 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 SubEnd Class*********************************************************************Best Regards,Dawn.Lee |
|
|
dmhampto
Starting Member
2 Posts |
Posted - 2009-05-13 : 19:23:23
|
If I recall correctly, if you're going to use Windows Authentication, you need to add "Integrated Security=True" to your connection string. Somebody please correct me if I'm wrong. I am fairly new at this.If nothing else, you could try setting it up through SQL Authentication instead of Windows Authentication, since then you elminate a variable and can just use a specified username/password until you're sure your app is connecting correctly.quote: - Shld I be using window authentication or sql server authentication?
I would say use Windows Authentication if you're in an environment that warrants it, such as a domain. For small personal projects and tests I like to use SQL Server Authentication since it eliminates a variable and uses a username/password structure that I'm familiar with. Once you know it's working, then you can make the changes for Windows Auth.quote: - do I nid another server to run btwn host and client if my database table is alr created in sql?
No, you just need the connector in code - and I can see you already have it set up through ADO.NET. Hopefully this was helpful to you... best of luck. |
 |
|
|
yuzhen
Starting Member
2 Posts |
Posted - 2009-05-13 : 21:38:53
|
my database table is created under window authentication login when i first start on my project. Now i hav ceated a new SQL Server authentication user and password but there is only database name (PatientInfo) w/o anything in the database table(pInfo), except a system thing. Like this: Is there somewhere i did wrong when i create a new login?Thanks.Best Regards,Dawn.Lee |
 |
|
|
dmhampto
Starting Member
2 Posts |
Posted - 2009-05-14 : 13:06:08
|
| My guess is that your new account doesn't have read rights on the database and/or table. The authentication mode that you use when creating the tables isn't important, but the ownership/permissions on databases is. Perhaps you need to pair your login with the appropriate user? |
 |
|
|
|
|
|
|
|