|
-
Jun 5th, 2007, 04:58 PM
#1
Thread Starter
New Member
PPC connection with MSSQL Express Edition
I've the following VB code to connect to MSSQL 2005 express edition:
Imports System.data.sqlclient
Imports System.Data.SqlServerCe
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CONStr As String = "Server=192.168.1.5;database=pos;user id=sa;password=123"
Dim ccon As New SqlConnection(CONStr)
Try
ccon.Open()
MsgBox(ccon.State)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
tried to write the port 1433 after I configured the sql setting to accept TCP/IP port 1433 and delete 0 from dynamic.
I wrote many connection string like:
"data source=192.168.1.5,1433\Sqlexpress;initial catalog=pos;user id= sa;password=123"
or
"data source=192.168.1.5\Sqlexpress;initial catalog=pos;user id= sa;password=123"
or
"data source=Mycom_name\Sqlexpress;initial catalog=pos;user id= sa;password=123"
the error message was (sql exception error) and another one was (a native exception has occurred in xyz.exe
what is the problem?
-
Jun 6th, 2007, 03:50 AM
#2
Fanatic Member
Re: PPC connection with MSSQL Express Edition
have you tried the following:
Try
sqlConn = New SqlConnection
sqlConn.ConnectionString = "Persist Security Info=False;Integrated Security=False;Server=<IPADDRESS\INSTANCE_NAME>,<PORT_NUMBER>;initial catalog=<DATABASE_NAME>;user id=<USER_NAME>;password=<PASSWORD>;"
sqlConn.Open()
Catch Ex As SqlClient.SqlException
End Try
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Jun 6th, 2007, 08:10 PM
#3
Thread Starter
New Member
Re: PPC connection with MSSQL Express Edition
Thanks for Reply.
but the same error message.
-
Jun 7th, 2007, 12:53 AM
#4
Frenzied Member
Re: PPC connection with MSSQL Express Edition
Hi
try it without the port number, or use the correct one, as I am pretty sure SqlExpress doesn't use 1433 as that is used by SqlServer
The string that works for me is:
Persist Security Info=False;Integrated Security=False;Server=ACERDUO\Sql2005;initial catalog=Waiter;user id=sa;password=xx;
Pete
-
Jun 7th, 2007, 05:35 AM
#5
Thread Starter
New Member
Re: PPC connection with MSSQL Express Edition
Hi,
First of all I'd like to thank you about your great reply.
but the problem as it is and I guess this problem from the emulator and I tried the device direct (Active sync Symbol PPC through Wifi).
(note: the network is running without any problem by ping all2all )
I tried this code with the emulator and the device but the error message result was different also I tried the code in Normal Windows application and it successed.
The same Problem is till now found?
Thanks
Waiting for solution..
-
Jun 7th, 2007, 07:39 AM
#6
Frenzied Member
Re: PPC connection with MSSQL Express Edition
Hi,
sorry - don't understand?
Are you saying it doesn't work in the emulator, or doesn't work on the device?
Pete
-
Jun 7th, 2007, 08:39 AM
#7
Thread Starter
New Member
Re: PPC connection with MSSQL Express Edition
-
Jun 7th, 2007, 12:12 PM
#8
Frenzied Member
Re: PPC connection with MSSQL Express Edition
HI,
in the try catch to
Try
... open code
Catch Ex as SqlCeException
displaySQLCeErrors(Ex)
End Try
and use this...
Public Sub DisplaySQLCEErrors(ByVal ex As SqlCeException)
Dim I As Int32
Dim strWork As String
strWork = "SqlCE Error " & vbCrLf
For I = 0 To ex.Errors.Count - 1
strWork = strWork & "Index #" & I & vbCrLf & "Error:" & ex.Errors(I).ToString()
Next
MsgBox(strWork, MsgBoxStyle.Information, "SQL Error")
End Sub
What error do you get?
-
Jun 11th, 2007, 03:12 AM
#9
Thread Starter
New Member
Re: PPC connection with MSSQL Express Edition
sqlCe Error
Index #0
Error:System.data.sqlclient.SqlError:invalid connection
-
Jun 11th, 2007, 06:51 AM
#10
Frenzied Member
Re: PPC connection with MSSQL Express Edition
Hi,
what connection string have you got now, and is this on the device or the emulator?
Pete
-
Jun 11th, 2007, 03:32 PM
#11
Thread Starter
New Member
Re: PPC connection with MSSQL Express Edition
Hi,
The Connection string is :
data source=192.168.1.5\Sqlexpress;initial catalog=pos;user id=sa;password=123 on the device.
Oss24
-
Jun 11th, 2007, 04:27 PM
#12
Frenzied Member
Re: PPC connection with MSSQL Express Edition
So you haven't used the string suggested by Strider or myself?
Persist Security Info=False;Integrated Security=False;Server=192.168.1.5\SqlExpress;initial catalog=pos;user id=sa;password=123;
Pete
-
Jun 11th, 2007, 05:11 PM
#13
Thread Starter
New Member
Re: PPC connection with MSSQL Express Edition
Hi,
The Code:
Imports System.data.sqlclient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Ccon As New SqlConnection("Persist Security Info=False;Integrated Security=False;Server=192.168.1.5\SqlExpress;initial catalog=pos;user id=sa;password=123;")
Try
Ccon.Open()
Catch ex As SqlException
DisplaySQLCEErrors(ex)
End Try
End Sub
Public Sub DisplaySQLCEErrors(ByVal ex As SqlException)
Dim I As Int32
Dim strWork As String
strWork = "SqlCE Error " & vbCrLf
For I = 0 To ex.Errors.Count - 1
strWork = strWork & "Index #" & I & vbCrLf & "Error:" & ex.Errors(I).ToString()
Next
MsgBox(strWork, MsgBoxStyle.Information, "SQL Error")
End Sub
End Class
the result is:
sqlCe Error
Index #0
Error:System.data.sqlclient.SqlError:
server not found:
192.168.1.5\sqlexpress
-
Jun 11th, 2007, 05:33 PM
#14
Thread Starter
New Member
Re: PPC connection with MSSQL Express Edition
Dear Pete,
First of all thanks a lot
Kindly, review the steps with me :
1. I configured the SQL Server Express Edition to accept the TCP/IP (enable)
2. Deleted for all Dynamic ports (remove Zeros) and assign the port 1433 for all - set to yes
3. restart the sql service.
4. connected through the ssmse (192.168.1.5\sqlexpress,1433 ) (user =sa & password = 123) so the connection succeeded
5. also tried to connect by computer name\sqlexpress and it succeeded
6. connected through another Desktop computer in my lab (succeeded)
7. Ping the Sql server computer from the PPC (succeeded )
8. tried to connect by many connection strings syntax (fail)
9. tried to connect using the emulator (fail)
10. in the ending I installed another MS Sql Server standard edition and tried to connect by the ppc device& the emulator but the result was the same.
may be I forgot some thing or it's a bad luck or .... !!!
P.S: I Know the the TCP Port 1433 isn't necessary when Sql Server Browser service running.
also I connected through the sqlcmd command line (succeeded)
What is the Problem.
Thanks
-
Jun 12th, 2007, 01:29 AM
#15
Frenzied Member
Re: PPC connection with MSSQL Express Edition
Hi,
I am now at a bit of a loss, as you appear to have tried everything.
I am still confused by port 1433 as that is what 2000 uses, although I use 2000 and 2005 on my system, so that may be different. Sql2005 uses 1125 and Express uses 1025 on my system.
Will check this out further when I get chance, as have just tried connecting to SqlExpress using this string and it fails, whereas connecting to Sql2005 works
Pete
-
Jun 12th, 2007, 07:07 AM
#16
Frenzied Member
Re: PPC connection with MSSQL Express Edition
Ok, after a bit of digging, try this (or similar)
Dim Ccon As New SqlConnection("Persist Security Info=False;Integrated Security=False;Server=beehive25,1068;initial catalog=Sales_Data;user id=sa;password=polaris;")
This was gleaned from http://netcf2.blogspot.com/2005/12/a...ress-from.html
It would appear you don't need to quote the instance
Pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|