Showing posts with label developing. Show all posts
Showing posts with label developing. Show all posts

Monday, March 19, 2012

Connecting to MSSQL Server 2000 using JDBC

Hello,

I am developing an application which needs JDBC connection to a Named Instance of SQL Server 2000 (other than default instance). I am facing problem in this regard as my code gives an exception "Time Out" or "Connection Failed". However it works fine with the default named instance...The main driver class is "com.microsoft.sqlserver.jdbc.SQLServerDriver"

and Connection URL is

"jdbc: sqlserver://localhost;instanceName=Testing:1432;databaseName=testDB;"

It gives the exception that Unable to connect to named instance....

Please if any one have any knowledge in this regard....do let me know....I have read an article on MSDN according to which on MS SQL Server 2000 the named Instance other than default can be accessed only through named pipes.

http://msdn2.microsoft.com/en-us/library/aa224779(sql.80).aspx

if some body can tell me Connection string for JDBC driver which utilizes named pipes...the it will be very help full for me.........any help from MSDN Experts is really appreciated...

Thanks

Muhammad:

The JDBC driver does connect to named instances but doesn't use Named Pipes -- only TCP/IP. In your case it looks like you're overloading the instanceName property in the connection string by putting the instanceName and portNumber together. Try breaking them apart like this:

"jdbc: sqlserver://localhost;instanceName=Testing;portNumber=1432;databaseName=testDB;"

If that still doesn't work let me know.

-shelby

|||

Thanks Shelby for your quick reply.....I have tried the string you have given and it is given the same error..

"com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect

at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)

at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)

at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(DriverManager.java:525)

at java.sql.DriverManager.getConnection(DriverManager.java:193)

at com.frt.test.DatabaseTest.main(DatabaseTest.java:21)"

One thing i want to discuss with you is that when I go to "Server Network utility" the value written in default port for the second instance in "TCP/IP" is 0..why it is so? I have chaged it to 1432 myself and have restarted the server again....My code is as follows (however it is very simple but I am sending it)

import java.sql.*;

public class DatabaseTest
{
public static void main(String[] args)
{
try
{
java.lang.Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" );
// Class.forName("com.inet.tds.TdsDriver");
Connection c = java.sql.DriverManager.getConnection( "jdbcTongue Tiedqlserver://localhost;instanceName=TESTING;portNumber=1432;databaseName=testDB;" );
// Connection c = java.sql.DriverManager.getConnection( "jdbcTongue Tiedqlserver://localhost/pipe/MSSQL$TESTING/sql/query?database=testDB&user=sa&password=abc");
// Connection c = DriverManager.getConnection("jdbc:inetdae7://localhost/pipe/MSSQL$TESTING/sql/query?database=CMS&user=sa&password=abc");
Statement s = c.createStatement();
ResultSet r =s.executeQuery("select * from table1");
while(r.next())
{
System.out.println(r.getString(2));
}
System.out.println( "Connected!" );
}
catch( Exception ex )
{
ex.printStackTrace();
}
}
}

as you can see that in connection statement I have commented out some lines....that is connection string of some other driver I have downloaded for testing...and when I use it with piped names it connects perfectly to named instance...but I have to use the first driver....so please help me...

Thanks for your coordination

bye

|||

At last i got the solution.....All the problem is due to cause that Service Pack 3.0 for SQL Server 2000 was not installed on my machine...as it is a bug in SQL Server 2000, that it does not listen on TCP/IP port, as u can verify by using TELNET, however this bug has been removed in SP3

Regards

Muhammad Ummar

Connecting to MSSQL Server 2000 using JDBC

Hello,

I am developing an application which needs JDBC connection to a Named Instance of SQL Server 2000 (other than default instance). I am facing problem in this regard as my code gives an exception "Time Out" or "Connection Failed". However it works fine with the default named instance...The main driver class is "com.microsoft.sqlserver.jdbc.SQLServerDriver"

and Connection URL is

"jdbc: sqlserver://localhost;instanceName=Testing:1432;databaseName=testDB;"

It gives the exception that Unable to connect to named instance....

Please if any one have any knowledge in this regard....do let me know....I have read an article on MSDN according to which on MS SQL Server 2000 the named Instance other than default can be accessed only through named pipes.

http://msdn2.microsoft.com/en-us/library/aa224779(sql.80).aspx

if some body can tell me Connection string for JDBC driver which utilizes named pipes...the it will be very help full for me.........any help from MSDN Experts is really appreciated...

Thanks

Muhammad:

The JDBC driver does connect to named instances but doesn't use Named Pipes -- only TCP/IP. In your case it looks like you're overloading the instanceName property in the connection string by putting the instanceName and portNumber together. Try breaking them apart like this:

"jdbc: sqlserver://localhost;instanceName=Testing;portNumber=1432;databaseName=testDB;"

If that still doesn't work let me know.

-shelby

|||

Thanks Shelby for your quick reply.....I have tried the string you have given and it is given the same error..

"com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect

at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)

at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)

at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(DriverManager.java:525)

at java.sql.DriverManager.getConnection(DriverManager.java:193)

at com.frt.test.DatabaseTest.main(DatabaseTest.java:21)"

One thing i want to discuss with you is that when I go to "Server Network utility" the value written in default port for the second instance in "TCP/IP" is 0..why it is so? I have chaged it to 1432 myself and have restarted the server again....My code is as follows (however it is very simple but I am sending it)

import java.sql.*;

public class DatabaseTest
{
public static void main(String[] args)
{
try
{
java.lang.Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" );
// Class.forName("com.inet.tds.TdsDriver");
Connection c = java.sql.DriverManager.getConnection( "jdbcTongue Tiedqlserver://localhost;instanceName=TESTING;portNumber=1432;databaseName=testDB;" );
// Connection c = java.sql.DriverManager.getConnection( "jdbcTongue Tiedqlserver://localhost/pipe/MSSQL$TESTING/sql/query?database=testDB&user=sa&password=abc");
// Connection c = DriverManager.getConnection("jdbc:inetdae7://localhost/pipe/MSSQL$TESTING/sql/query?database=CMS&user=sa&password=abc");
Statement s = c.createStatement();
ResultSet r =s.executeQuery("select * from table1");
while(r.next())
{
System.out.println(r.getString(2));
}
System.out.println( "Connected!" );
}
catch( Exception ex )
{
ex.printStackTrace();
}
}
}

as you can see that in connection statement I have commented out some lines....that is connection string of some other driver I have downloaded for testing...and when I use it with piped names it connects perfectly to named instance...but I have to use the first driver....so please help me...

Thanks for your coordination

bye

|||

At last i got the solution.....All the problem is due to cause that Service Pack 3.0 for SQL Server 2000 was not installed on my machine...as it is a bug in SQL Server 2000, that it does not listen on TCP/IP port, as u can verify by using TELNET, however this bug has been removed in SP3

Regards

Muhammad Ummar

Thursday, March 8, 2012

Connecting to Analysis Services on different domain

Does anyone know how I can connecting to an analysis services cube that
is located on a different server/domain than the one I am developing
the report on.
I am able to remote connect to the server and process the cube, however
I don't know how to create a connection to the cube.
I am woring on the corp domain and the cube is located on the corp2
domain, server name cr2rchmiis10.
Thanks in advance for any help.
John CCan you set up a SQL linked server on a SQL server in the corp domain
that connects to the AS in the corp2 domain?
If you can get the linked server set up across domains, you can run
your query against the linked server in the corp domain.|||If you are using Analysis Services ENTERPRISE edition, you can connect to
Analysis Services through Http, and that would probably solve your problem.
If you are using AS Standard edition, you need to do something else. (Like
Potter suggested.)
With Analysis Services 2005 Enterprise edition
http://www.microsoft.com/technet/prodtechnol/sql/2005/httpasws.mspx
With ANalysis Services 2000 Enterprise edition:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/olapdmad/aghtconfig_4giq.asp
Kaisa
<john.r.carter@.bankofamerica.com> wrote in message
news:1135094407.938804.228280@.g14g2000cwa.googlegroups.com...
> Does anyone know how I can connecting to an analysis services cube that
> is located on a different server/domain than the one I am developing
> the report on.
> I am able to remote connect to the server and process the cube, however
> I don't know how to create a connection to the cube.
> I am woring on the corp domain and the cube is located on the corp2
> domain, server name cr2rchmiis10.
> Thanks in advance for any help.
> John C
>

Connecting to an external server

Hi,
I have been developing an app using SQL Server 2000 and am ready to transfer to a server located offsite. How can I connect to this server through enterprise manager or anything else so that I can use the copydatabase wizard to move it to the live server?
Thanks
WheelzPerhaps I'm missing something here (wouldn't be the first time, I'll grant ya that ;) ) but if it's on your server network, you just add the server to your "SQL Server Group" in the enterprise manager, and then you can transfer stuff willy-nilly.

Right-click on the SQL Server Group in the console file system pane of the Enterprise Manager, then add the remote server.

Like I said, I may be missing something, but if the remote server is accessable from your network, you oughta be good to go, I would think. :?:|||Hi,
I've done what you said and it offers me to register a new instance or a new group. Either one of these doesn't let me specify an IP address to the live server.|||You should regiustering a server alias..

And that has to be added....to....Damn a network question...

I forget...

But it's good to do this in case you have to flip th ip for disaster purposes...

I'll go look...|||Check this out

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=36034&SearchTerms=server,alias,

Wednesday, March 7, 2012

Connecting to a remote sql server problems, please help

I am currently developing a 2.0 asp.net application from my home pc (Windows XP) and am trying to connect to a sql server on my host. This works fine at work but at home I just get the following error message:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Any ideas, i have even tried disabling my firewall to see if that made a difference.

Your help is much appreciated.

Under SQL2005 program menu follow configuration Tools =>SQL Server Surface Area Configuration => Select Server Surface Area Configuration for Services and Connections.

It will lead to a window with a treeview select Remote connections.Then Select Local and Remote Connections.

Thats it now you can connect your SQL Server without any problem

|||

Thanks for the reply, however, it seems as if the problem was with the router i was using. After making some port changes it works just fine.

Thanks

Sunday, February 19, 2012

connecting DB on a pendrive in MSSQL 7.0

I am developing an application in VB. I want to know whether we can keep the database file (.mdf) on the pendrive in MS SQL 7.0. If this can be done HOW CAN THIS BE DONE Please guide me. It should be that when i connect my pendrive to the machine / server then i should be able to acess the database. This is a chellenging job which i have taken. Please guide me if this is possible.
Hoping for you HELP
THank YOu
Vikram JainCheck out sp_attach_db and sp_detach_db in the MS-SQL 7.0 Books Online.

-PatP|||SP_Attach_DB ?? How can this procedure be made run through VB Code.
If you can send me a sample code it would be highly appreciated..
Thanks Regards Vikram Jain

Sunday, February 12, 2012

Connect to sqlexpress from network computer

Hi

Please if any one can answer.I am developing .net vb app sqlexpress database.

In single user work ok.In multiuser from other computer on network I cannot get data.Any form without data workok fine . The error I am getting is as follows.

Application attempted to perform operation not allowed by the security policy.

request for permission of type

'System.data.sqlclientpermission,system.data,

version=2.0.0.0.,culture=Normal, publickeytoken=b77a5c561934e089'

Zaabdullah

Hi Zaabdullah,

You will most likely get a better response by posting on one of the VB.NET forums. It seems that the security policy for the Assembly needs to be corrected to allow accessing resources across the network.

Connect to SQL Server from a PDA

Hi,

I'm developing Pocket Pc application, my application establishes connection with a SQL Server Express 2005 Database. When I try to connect to the database I get an error "SQLexception", when i deploy and run my application both on my physical PDA (HP iPAQ) and the Pocket PC 2003 emulator in Visual Studio 2005. I am working in .Net Compact Framework 2.0 and my PDA runs Windows Mobile 5.0 . Can any one help me to solve this issue?

I use this code:

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=SSPI;User ID=uid;Password=pwd";

myconnection = new SqlConnection(connstring);

myconnection.Open();

and this is part of the errormessage:

System.Data.SqlClient.SqlExceptionTongue TiedqlException at System.Data.SqlClient.SqlConnection.OnError() at

When connecting to SQL Server from Compact Framework code using the SqlClient, you should not use the DNS name of the server but rather Data Source = {IPADDRESS}/{SQL INSTANCE NAME} and make sure you have used the SQL SERVER CONFIGURATION TOOLS to enable remote connections and the TCPIP protocol to the running instance of SQL SERVER. So if my machine is 204.21.46.34 and my SQL Express instance is the default (SQLEXPRESS), I'd need to use Data Source = 204.21.46.34/SQLEXPRESS in my connection string.

If that does not resolve your issue, please post the exception details because something else may be going on.

-Darren

|||

You are mixing SQL security and integrated security - remove "Integrated Security=SSPI" from your connection string.

|||

Hi Darren,

Unfortunately it didn't solve my problem, here is the complete stacktrace:

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||

I've changed my connection string to

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;User ID=uid; Password=pwd";

but it didn't solve my problem.

/JO

|||

Which error and error message do you get?

|||

Hi Erik,

This is the stacktrace;

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||Yes, but what exception are you getting and what is the error message?|||

SqlException has error collection with error messages which you should print out, there's a code sample on MSDN (about one page of code).

But I would guess it would simply tell you it can't establish connection. Please follow this troubleshooting procedure in that case. If you not networking savvy ask your network administrator for help. Also see this.

|||

Hi Erik,

The exception is:

System.Data.SqlClient.SqlException

The error message is:

Specified SQL-server not found.

The SQL-server is my developmentcomputer, I run both the application and SQL-server on the same PC. I can attach and open the database from Server Explorer in VS2005.

/JO

|||

The first thing I would do is make sure your instance of SQL Server is configured to accept connections.

Run the SQL Server Configuration Manager (Start->Microsoft SQL Server 2005->Configuration Tools->SQL Server Configuration Manager) and do two things:

1. make sure you understand the exact name of the SQL Server Instance you have installed. In your connection string, you are using MYSERVER and if there is more than one instance of SQL Server -or- you installed with a named instance, MYSERVER as the server name will not work. Again, I encourage you to use the IP address versus the server name when connecting from a device.

2. Open the SQL Server 2005 Network Configuration node and select the instance of SQL Server you are interested in your mobile app connecting to. Go ahead and for now, Enable all of the protocols except for VIA.

Now go back to your mobile device and try to connect. It is confusing to me where your mobile app is running - in an earlier post you indicated it was a Pocket PC app which I assume you have deployed to an actual device connected to your dev machine via ActiveSync. In this last post, you're saying the application is running on your development PC. Maybe we'd better clarify that:

a. this is a Compact Framework 2.0 app

b. you are deploying it to an actual device and then trying to connect via ActiveSync or WiFi. You can open Pocket IE on your device and hit a URL on your dev machine (a great test of the network path between device and server).

c. if you are deploying to an emulator, you have verified that the network connectivity on the emulator is correctly setup to talk to your PC. This usually means enabling the LAN adapter, using Device Emulator Manager to cradle the device, and setting up a proxy on the emulator to allow your Work Network to get to your dev machine.

d. your dev machine running SQL Server has an IP address and network connection as you are testing. If it does not, you need to have the MS Loopback adapter installed and active.

-Darren

|||

Sorry Darren;

I really dont want to confuse you, it's enogh me beeing confused.

The application is not running on my development PC it runs on the Pocket PC, what I mean is that i develop the application on a developmentPC and use Active Sync to deploy it on my PPC.

I run SQL Server Express 2005.

this is my coonection string:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS;Initial Catalog=C:\DYNAMICS\APP\CLAMATORVOICESYSTEM\ALARMHISTORY\SQLSERVER\ALARMHISTORY.MDF;Integrated Security=True";

I can ping from my SQL-server to the PPC.

/JO

|||

this helps - the connection string all looks good except I am not sure (which means it's probably an issue) that the mobile version of the SQL Client can handle an Initial Catalog that specifies the attachable DB file. Go ahead and restore your ALARMHISTORY.MDF file into your SQL Express instance (it might already be there) and change the Initial Catalog to ALARMHISTORY.

-Darren

|||

darren,

I made the suggested changes and something has haoppend, I now get this error message:

"A native error has occurd in myapplication.exe. Select Quit and restart the program orselect Details for mor information."

This is my connectionstring:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS,;Initial Catalog=ALARMHISTORY;Integrated Security=True";

/JO

|||

maybe you must delete the comma after SQLEXPRESS

and add:

;user id=<user>;password=<password>

by the way with these string i can connect to my sql server express:

- after configure network adapter in the pocketpc emulator

- after configure network settings in the windows ce

- after configure properly sql server network protocols

- after configure user in sql server

etc...

Connect to SQL Server from a PDA

Hi,

I'm developing Pocket Pc application, my application establishes connection with a SQL Server Express 2005 Database. When I try to connect to the database I get an error "SQLexception", when i deploy and run my application both on my physical PDA (HP iPAQ) and the Pocket PC 2003 emulator in Visual Studio 2005. I am working in .Net Compact Framework 2.0 and my PDA runs Windows Mobile 5.0 . Can any one help me to solve this issue?

I use this code:

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=SSPI;User ID=uid;Password=pwd";

myconnection = new SqlConnection(connstring);

myconnection.Open();

and this is part of the errormessage:

System.Data.SqlClient.SqlExceptionTongue TiedqlException at System.Data.SqlClient.SqlConnection.OnError() at

When connecting to SQL Server from Compact Framework code using the SqlClient, you should not use the DNS name of the server but rather Data Source = {IPADDRESS}/{SQL INSTANCE NAME} and make sure you have used the SQL SERVER CONFIGURATION TOOLS to enable remote connections and the TCPIP protocol to the running instance of SQL SERVER. So if my machine is 204.21.46.34 and my SQL Express instance is the default (SQLEXPRESS), I'd need to use Data Source = 204.21.46.34/SQLEXPRESS in my connection string.

If that does not resolve your issue, please post the exception details because something else may be going on.

-Darren

|||

You are mixing SQL security and integrated security - remove "Integrated Security=SSPI" from your connection string.

|||

Hi Darren,

Unfortunately it didn't solve my problem, here is the complete stacktrace:

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||

I've changed my connection string to

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;User ID=uid; Password=pwd";

but it didn't solve my problem.

/JO

|||

Which error and error message do you get?

|||

Hi Erik,

This is the stacktrace;

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||Yes, but what exception are you getting and what is the error message?|||

SqlException has error collection with error messages which you should print out, there's a code sample on MSDN (about one page of code).

But I would guess it would simply tell you it can't establish connection. Please follow this troubleshooting procedure in that case. If you not networking savvy ask your network administrator for help. Also see this.

|||

Hi Erik,

The exception is:

System.Data.SqlClient.SqlException

The error message is:

Specified SQL-server not found.

The SQL-server is my developmentcomputer, I run both the application and SQL-server on the same PC. I can attach and open the database from Server Explorer in VS2005.

/JO

|||

The first thing I would do is make sure your instance of SQL Server is configured to accept connections.

Run the SQL Server Configuration Manager (Start->Microsoft SQL Server 2005->Configuration Tools->SQL Server Configuration Manager) and do two things:

1. make sure you understand the exact name of the SQL Server Instance you have installed. In your connection string, you are using MYSERVER and if there is more than one instance of SQL Server -or- you installed with a named instance, MYSERVER as the server name will not work. Again, I encourage you to use the IP address versus the server name when connecting from a device.

2. Open the SQL Server 2005 Network Configuration node and select the instance of SQL Server you are interested in your mobile app connecting to. Go ahead and for now, Enable all of the protocols except for VIA.

Now go back to your mobile device and try to connect. It is confusing to me where your mobile app is running - in an earlier post you indicated it was a Pocket PC app which I assume you have deployed to an actual device connected to your dev machine via ActiveSync. In this last post, you're saying the application is running on your development PC. Maybe we'd better clarify that:

a. this is a Compact Framework 2.0 app

b. you are deploying it to an actual device and then trying to connect via ActiveSync or WiFi. You can open Pocket IE on your device and hit a URL on your dev machine (a great test of the network path between device and server).

c. if you are deploying to an emulator, you have verified that the network connectivity on the emulator is correctly setup to talk to your PC. This usually means enabling the LAN adapter, using Device Emulator Manager to cradle the device, and setting up a proxy on the emulator to allow your Work Network to get to your dev machine.

d. your dev machine running SQL Server has an IP address and network connection as you are testing. If it does not, you need to have the MS Loopback adapter installed and active.

-Darren

|||

Sorry Darren;

I really dont want to confuse you, it's enogh me beeing confused.

The application is not running on my development PC it runs on the Pocket PC, what I mean is that i develop the application on a developmentPC and use Active Sync to deploy it on my PPC.

I run SQL Server Express 2005.

this is my coonection string:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS;Initial Catalog=C:\DYNAMICS\APP\CLAMATORVOICESYSTEM\ALARMHISTORY\SQLSERVER\ALARMHISTORY.MDF;Integrated Security=True";

I can ping from my SQL-server to the PPC.

/JO

|||

this helps - the connection string all looks good except I am not sure (which means it's probably an issue) that the mobile version of the SQL Client can handle an Initial Catalog that specifies the attachable DB file. Go ahead and restore your ALARMHISTORY.MDF file into your SQL Express instance (it might already be there) and change the Initial Catalog to ALARMHISTORY.

-Darren

|||

darren,

I made the suggested changes and something has haoppend, I now get this error message:

"A native error has occurd in myapplication.exe. Select Quit and restart the program orselect Details for mor information."

This is my connectionstring:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS,;Initial Catalog=ALARMHISTORY;Integrated Security=True";

/JO

|||

maybe you must delete the comma after SQLEXPRESS

and add:

;user id=<user>;password=<password>

by the way with these string i can connect to my sql server express:

- after configure network adapter in the pocketpc emulator

- after configure network settings in the windows ce

- after configure properly sql server network protocols

- after configure user in sql server

etc...

Connect to SQL Server from a PDA

Hi,

I'm developing Pocket Pc application, my application establishes connection with a SQL Server Express 2005 Database. When I try to connect to the database I get an error "SQLexception", when i deploy and run my application both on my physical PDA (HP iPAQ) and the Pocket PC 2003 emulator in Visual Studio 2005. I am working in .Net Compact Framework 2.0 and my PDA runs Windows Mobile 5.0 . Can any one help me to solve this issue?

I use this code:

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=SSPI;User ID=uid;Password=pwd";

myconnection = new SqlConnection(connstring);

myconnection.Open();

and this is part of the errormessage:

System.Data.SqlClient.SqlExceptionTongue TiedqlException at System.Data.SqlClient.SqlConnection.OnError() at

When connecting to SQL Server from Compact Framework code using the SqlClient, you should not use the DNS name of the server but rather Data Source = {IPADDRESS}/{SQL INSTANCE NAME} and make sure you have used the SQL SERVER CONFIGURATION TOOLS to enable remote connections and the TCPIP protocol to the running instance of SQL SERVER. So if my machine is 204.21.46.34 and my SQL Express instance is the default (SQLEXPRESS), I'd need to use Data Source = 204.21.46.34/SQLEXPRESS in my connection string.

If that does not resolve your issue, please post the exception details because something else may be going on.

-Darren

|||

You are mixing SQL security and integrated security - remove "Integrated Security=SSPI" from your connection string.

|||

Hi Darren,

Unfortunately it didn't solve my problem, here is the complete stacktrace:

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||

I've changed my connection string to

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;User ID=uid; Password=pwd";

but it didn't solve my problem.

/JO

|||

Which error and error message do you get?

|||

Hi Erik,

This is the stacktrace;

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||Yes, but what exception are you getting and what is the error message?|||

SqlException has error collection with error messages which you should print out, there's a code sample on MSDN (about one page of code).

But I would guess it would simply tell you it can't establish connection. Please follow this troubleshooting procedure in that case. If you not networking savvy ask your network administrator for help. Also see this.

|||

Hi Erik,

The exception is:

System.Data.SqlClient.SqlException

The error message is:

Specified SQL-server not found.

The SQL-server is my developmentcomputer, I run both the application and SQL-server on the same PC. I can attach and open the database from Server Explorer in VS2005.

/JO

|||

The first thing I would do is make sure your instance of SQL Server is configured to accept connections.

Run the SQL Server Configuration Manager (Start->Microsoft SQL Server 2005->Configuration Tools->SQL Server Configuration Manager) and do two things:

1. make sure you understand the exact name of the SQL Server Instance you have installed. In your connection string, you are using MYSERVER and if there is more than one instance of SQL Server -or- you installed with a named instance, MYSERVER as the server name will not work. Again, I encourage you to use the IP address versus the server name when connecting from a device.

2. Open the SQL Server 2005 Network Configuration node and select the instance of SQL Server you are interested in your mobile app connecting to. Go ahead and for now, Enable all of the protocols except for VIA.

Now go back to your mobile device and try to connect. It is confusing to me where your mobile app is running - in an earlier post you indicated it was a Pocket PC app which I assume you have deployed to an actual device connected to your dev machine via ActiveSync. In this last post, you're saying the application is running on your development PC. Maybe we'd better clarify that:

a. this is a Compact Framework 2.0 app

b. you are deploying it to an actual device and then trying to connect via ActiveSync or WiFi. You can open Pocket IE on your device and hit a URL on your dev machine (a great test of the network path between device and server).

c. if you are deploying to an emulator, you have verified that the network connectivity on the emulator is correctly setup to talk to your PC. This usually means enabling the LAN adapter, using Device Emulator Manager to cradle the device, and setting up a proxy on the emulator to allow your Work Network to get to your dev machine.

d. your dev machine running SQL Server has an IP address and network connection as you are testing. If it does not, you need to have the MS Loopback adapter installed and active.

-Darren

|||

Sorry Darren;

I really dont want to confuse you, it's enogh me beeing confused.

The application is not running on my development PC it runs on the Pocket PC, what I mean is that i develop the application on a developmentPC and use Active Sync to deploy it on my PPC.

I run SQL Server Express 2005.

this is my coonection string:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS;Initial Catalog=C:\DYNAMICS\APP\CLAMATORVOICESYSTEM\ALARMHISTORY\SQLSERVER\ALARMHISTORY.MDF;Integrated Security=True";

I can ping from my SQL-server to the PPC.

/JO

|||

this helps - the connection string all looks good except I am not sure (which means it's probably an issue) that the mobile version of the SQL Client can handle an Initial Catalog that specifies the attachable DB file. Go ahead and restore your ALARMHISTORY.MDF file into your SQL Express instance (it might already be there) and change the Initial Catalog to ALARMHISTORY.

-Darren

|||

darren,

I made the suggested changes and something has haoppend, I now get this error message:

"A native error has occurd in myapplication.exe. Select Quit and restart the program orselect Details for mor information."

This is my connectionstring:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS,;Initial Catalog=ALARMHISTORY;Integrated Security=True";

/JO

|||

maybe you must delete the comma after SQLEXPRESS

and add:

;user id=<user>;password=<password>

by the way with these string i can connect to my sql server express:

- after configure network adapter in the pocketpc emulator

- after configure network settings in the windows ce

- after configure properly sql server network protocols

- after configure user in sql server

etc...

Connect to SQL Server from a PDA

Hi,

I'm developing Pocket Pc application, my application establishes connection with a SQL Server Express 2005 Database. When I try to connect to the database I get an error "SQLexception", when i deploy and run my application both on my physical PDA (HP iPAQ) and the Pocket PC 2003 emulator in Visual Studio 2005. I am working in .Net Compact Framework 2.0 and my PDA runs Windows Mobile 5.0 . Can any one help me to solve this issue?

I use this code:

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=SSPI;User ID=uid;Password=pwd";

myconnection = new SqlConnection(connstring);

myconnection.Open();

and this is part of the errormessage:

System.Data.SqlClient.SqlExceptionTongue TiedqlException at System.Data.SqlClient.SqlConnection.OnError() at

When connecting to SQL Server from Compact Framework code using the SqlClient, you should not use the DNS name of the server but rather Data Source = {IPADDRESS}/{SQL INSTANCE NAME} and make sure you have used the SQL SERVER CONFIGURATION TOOLS to enable remote connections and the TCPIP protocol to the running instance of SQL SERVER. So if my machine is 204.21.46.34 and my SQL Express instance is the default (SQLEXPRESS), I'd need to use Data Source = 204.21.46.34/SQLEXPRESS in my connection string.

If that does not resolve your issue, please post the exception details because something else may be going on.

-Darren

|||

You are mixing SQL security and integrated security - remove "Integrated Security=SSPI" from your connection string.

|||

Hi Darren,

Unfortunately it didn't solve my problem, here is the complete stacktrace:

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||

I've changed my connection string to

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;User ID=uid; Password=pwd";

but it didn't solve my problem.

/JO

|||

Which error and error message do you get?

|||

Hi Erik,

This is the stacktrace;

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||Yes, but what exception are you getting and what is the error message?|||

SqlException has error collection with error messages which you should print out, there's a code sample on MSDN (about one page of code).

But I would guess it would simply tell you it can't establish connection. Please follow this troubleshooting procedure in that case. If you not networking savvy ask your network administrator for help. Also see this.

|||

Hi Erik,

The exception is:

System.Data.SqlClient.SqlException

The error message is:

Specified SQL-server not found.

The SQL-server is my developmentcomputer, I run both the application and SQL-server on the same PC. I can attach and open the database from Server Explorer in VS2005.

/JO

|||

The first thing I would do is make sure your instance of SQL Server is configured to accept connections.

Run the SQL Server Configuration Manager (Start->Microsoft SQL Server 2005->Configuration Tools->SQL Server Configuration Manager) and do two things:

1. make sure you understand the exact name of the SQL Server Instance you have installed. In your connection string, you are using MYSERVER and if there is more than one instance of SQL Server -or- you installed with a named instance, MYSERVER as the server name will not work. Again, I encourage you to use the IP address versus the server name when connecting from a device.

2. Open the SQL Server 2005 Network Configuration node and select the instance of SQL Server you are interested in your mobile app connecting to. Go ahead and for now, Enable all of the protocols except for VIA.

Now go back to your mobile device and try to connect. It is confusing to me where your mobile app is running - in an earlier post you indicated it was a Pocket PC app which I assume you have deployed to an actual device connected to your dev machine via ActiveSync. In this last post, you're saying the application is running on your development PC. Maybe we'd better clarify that:

a. this is a Compact Framework 2.0 app

b. you are deploying it to an actual device and then trying to connect via ActiveSync or WiFi. You can open Pocket IE on your device and hit a URL on your dev machine (a great test of the network path between device and server).

c. if you are deploying to an emulator, you have verified that the network connectivity on the emulator is correctly setup to talk to your PC. This usually means enabling the LAN adapter, using Device Emulator Manager to cradle the device, and setting up a proxy on the emulator to allow your Work Network to get to your dev machine.

d. your dev machine running SQL Server has an IP address and network connection as you are testing. If it does not, you need to have the MS Loopback adapter installed and active.

-Darren

|||

Sorry Darren;

I really dont want to confuse you, it's enogh me beeing confused.

The application is not running on my development PC it runs on the Pocket PC, what I mean is that i develop the application on a developmentPC and use Active Sync to deploy it on my PPC.

I run SQL Server Express 2005.

this is my coonection string:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS;Initial Catalog=C:\DYNAMICS\APP\CLAMATORVOICESYSTEM\ALARMHISTORY\SQLSERVER\ALARMHISTORY.MDF;Integrated Security=True";

I can ping from my SQL-server to the PPC.

/JO

|||

this helps - the connection string all looks good except I am not sure (which means it's probably an issue) that the mobile version of the SQL Client can handle an Initial Catalog that specifies the attachable DB file. Go ahead and restore your ALARMHISTORY.MDF file into your SQL Express instance (it might already be there) and change the Initial Catalog to ALARMHISTORY.

-Darren

|||

darren,

I made the suggested changes and something has haoppend, I now get this error message:

"A native error has occurd in myapplication.exe. Select Quit and restart the program orselect Details for mor information."

This is my connectionstring:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS,;Initial Catalog=ALARMHISTORY;Integrated Security=True";

/JO

|||

maybe you must delete the comma after SQLEXPRESS

and add:

;user id=<user>;password=<password>

by the way with these string i can connect to my sql server express:

- after configure network adapter in the pocketpc emulator

- after configure network settings in the windows ce

- after configure properly sql server network protocols

- after configure user in sql server

etc...

Connect to SQL Server from a PDA

Hi,

I'm developing Pocket Pc application, my application establishes connection with a SQL Server Express 2005 Database. When I try to connect to the database I get an error "SQLexception", when i deploy and run my application both on my physical PDA (HP iPAQ) and the Pocket PC 2003 emulator in Visual Studio 2005. I am working in .Net Compact Framework 2.0 and my PDA runs Windows Mobile 5.0 . Can any one help me to solve this issue?

I use this code:

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=SSPI;User ID=uid;Password=pwd";

myconnection = new SqlConnection(connstring);

myconnection.Open();

and this is part of the errormessage:

System.Data.SqlClient.SqlExceptionTongue TiedqlException at System.Data.SqlClient.SqlConnection.OnError() at

When connecting to SQL Server from Compact Framework code using the SqlClient, you should not use the DNS name of the server but rather Data Source = {IPADDRESS}/{SQL INSTANCE NAME} and make sure you have used the SQL SERVER CONFIGURATION TOOLS to enable remote connections and the TCPIP protocol to the running instance of SQL SERVER. So if my machine is 204.21.46.34 and my SQL Express instance is the default (SQLEXPRESS), I'd need to use Data Source = 204.21.46.34/SQLEXPRESS in my connection string.

If that does not resolve your issue, please post the exception details because something else may be going on.

-Darren

|||

You are mixing SQL security and integrated security - remove "Integrated Security=SSPI" from your connection string.

|||

Hi Darren,

Unfortunately it didn't solve my problem, here is the complete stacktrace:

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||

I've changed my connection string to

string connstring = @."Data Source=myserver;Initial Catalog=mydatabase;User ID=uid; Password=pwd";

but it didn't solve my problem.

/JO

|||

Which error and error message do you get?

|||

Hi Erik,

This is the stacktrace;

at System.Data.SqlClient.SqlConnection.OnError() at System.Data.SqlClient.SqlInternalConnection.OnError() at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect() at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin() at System.Data.SqlClient.SqlInternalConnection..ctor() at System.Data.SqlClient.SqlConnection.Open() at DeviceApplication3.Form1.readDatabase() at DeviceApplication3.Form1.btnOpenDB_Click() at System.Windows.Forms.Control.OnClick() at System.Windows.Forms.Button.OnClick() at System.Windows.Forms.ButtonBase.WnProc() at System.Windows.Forms.Control._InternalWnProc() at Microsoft.AGL.Forms.EVL.EnterMainLoop() at System.Windows.Forms.Application.Run() at DeviceApplication3.Program.Main()

/JO

|||Yes, but what exception are you getting and what is the error message?|||

SqlException has error collection with error messages which you should print out, there's a code sample on MSDN (about one page of code).

But I would guess it would simply tell you it can't establish connection. Please follow this troubleshooting procedure in that case. If you not networking savvy ask your network administrator for help. Also see this.

|||

Hi Erik,

The exception is:

System.Data.SqlClient.SqlException

The error message is:

Specified SQL-server not found.

The SQL-server is my developmentcomputer, I run both the application and SQL-server on the same PC. I can attach and open the database from Server Explorer in VS2005.

/JO

|||

The first thing I would do is make sure your instance of SQL Server is configured to accept connections.

Run the SQL Server Configuration Manager (Start->Microsoft SQL Server 2005->Configuration Tools->SQL Server Configuration Manager) and do two things:

1. make sure you understand the exact name of the SQL Server Instance you have installed. In your connection string, you are using MYSERVER and if there is more than one instance of SQL Server -or- you installed with a named instance, MYSERVER as the server name will not work. Again, I encourage you to use the IP address versus the server name when connecting from a device.

2. Open the SQL Server 2005 Network Configuration node and select the instance of SQL Server you are interested in your mobile app connecting to. Go ahead and for now, Enable all of the protocols except for VIA.

Now go back to your mobile device and try to connect. It is confusing to me where your mobile app is running - in an earlier post you indicated it was a Pocket PC app which I assume you have deployed to an actual device connected to your dev machine via ActiveSync. In this last post, you're saying the application is running on your development PC. Maybe we'd better clarify that:

a. this is a Compact Framework 2.0 app

b. you are deploying it to an actual device and then trying to connect via ActiveSync or WiFi. You can open Pocket IE on your device and hit a URL on your dev machine (a great test of the network path between device and server).

c. if you are deploying to an emulator, you have verified that the network connectivity on the emulator is correctly setup to talk to your PC. This usually means enabling the LAN adapter, using Device Emulator Manager to cradle the device, and setting up a proxy on the emulator to allow your Work Network to get to your dev machine.

d. your dev machine running SQL Server has an IP address and network connection as you are testing. If it does not, you need to have the MS Loopback adapter installed and active.

-Darren

|||

Sorry Darren;

I really dont want to confuse you, it's enogh me beeing confused.

The application is not running on my development PC it runs on the Pocket PC, what I mean is that i develop the application on a developmentPC and use Active Sync to deploy it on my PPC.

I run SQL Server Express 2005.

this is my coonection string:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS;Initial Catalog=C:\DYNAMICS\APP\CLAMATORVOICESYSTEM\ALARMHISTORY\SQLSERVER\ALARMHISTORY.MDF;Integrated Security=True";

I can ping from my SQL-server to the PPC.

/JO

|||

this helps - the connection string all looks good except I am not sure (which means it's probably an issue) that the mobile version of the SQL Client can handle an Initial Catalog that specifies the attachable DB file. Go ahead and restore your ALARMHISTORY.MDF file into your SQL Express instance (it might already be there) and change the Initial Catalog to ALARMHISTORY.

-Darren

|||

darren,

I made the suggested changes and something has haoppend, I now get this error message:

"A native error has occurd in myapplication.exe. Select Quit and restart the program orselect Details for mor information."

This is my connectionstring:

connstring = @."Data Source=85.225.253.196\SQLEXPRESS,;Initial Catalog=ALARMHISTORY;Integrated Security=True";

/JO

|||

maybe you must delete the comma after SQLEXPRESS

and add:

;user id=<user>;password=<password>

by the way with these string i can connect to my sql server express:

- after configure network adapter in the pocketpc emulator

- after configure network settings in the windows ce

- after configure properly sql server network protocols

- after configure user in sql server

etc...