Showing posts with label project. Show all posts
Showing posts with label project. Show all posts

Sunday, March 25, 2012

Connecting to SQL Mobile within VS-2005

I am getting an error when I run my project within VS2005. I am trying to connect to a SQL Mobile (sdf) file thru code using a connection string. As soon as run my project within the VS2005 environment, I get the following error when the code tries to connect:
"The file is not a valid database file. An internal error has occurred. [,,,Databasename,,]"
The source of the error is: Microsoft SQL Server 2000 Windows CE Edition
Native Error of: 25011
I am am deploying to POcket PC 2003 SE Emulator.
This code worked fine in VS2003 with SQLCE 2.0. But I have now updated the projects to VS2005 and recreated the database sdf file within the VS2005 environment.
Could someone please help me ASAP?
Thanks.

There is no database compatibility between SQL CE 2.0 and SQL Mobile. Database created through one cannot be opened by other. In you case, since you have upgraded the project and re-created the database, you have SQL Mobile database. But your application still has references to SQL CE 2.0 provider. So now your application is trying to open a SQL CE 3.0 Database using SQL CE 2.0 provider; that’s the reason why in your error string you can see

The source of the error is: Microsoft SQL Server 2000 Windows CE Edition
Native Error of: 25011

In you application you need to remove the reference from 2.0 provider and add reference to 3.0 provider.

Thanks

-Mani

Connecting to SQL Express 2005 via Web.Config file in Visual Studio 2003

Hi

I am following a project to build a small E-Commerce site from a book I have purchased and I have having problems connecting to the SQL Database with the code supplied.

The book is Apress Beginning ASP.NET 1.1 E-Commerce

http://www.amazon.co.uk/Beginning-ASP-Net-1-1-E-Commerce-Professional/dp/1590592549/ref=sr_11_1/202-7684451-7995058?ie=UTF8&qid=1193780707&sr=11-1

The code added to the Web.Config file is :

<configuration>

<appSettings>

<addkey="ConnectionString"value="Server=(local)\NetSDK;Integrated Security=True;Initial Catalog=JokePoint"/>

</appSettings>

The connection details are in a class file called Catalog.vb and is as follows

Imports System.Data.SqlClient

PublicClass Catalog

PublicSharedFunction GetDepartments()As SqlDataReader

'Create the connection object

Dim connectionAsNew SqlConnection(connectionString)

'Create and initialize the command object

Dim commandAsNew SqlCommand("GetDepartments", connection)

command.CommandType = CommandType.StoredProcedure

'Open the connection

connection.Open()

'Return a SqlDataReader to the calling function

Return command.ExecuteReader(CommandBehavior.CloseConnection)

EndFunction

PrivateSharedReadOnlyProperty connectionString()AsString

Get

Return ConfigurationSettings.AppSettings("ConnectionString")

EndGet

EndProperty

EndClass

The error is....

Cannot open database "JokePoint" requested by the login. The login failed. Login failed for user 'MachineName\ASPNET'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Cannot open database "JokePoint" requested by the login. The login failed. Login failed for user 'MachineName\ASPNET'.

Source Error:

Line 15: 'Open the connectionLine 16:Line 17: connection.Open()Line 18: Line 19: 'Return a SqlDataReader to the calling function


Source File:C:\MyCommerceSite\JokePoint\BusinessObjects\Catalog.vb Line:17

Stack Trace:

[SqlException: Cannot open database "JokePoint" requested by the login. The login failed.Login failed for user 'MachineName\ASPNET'.] System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) System.Data.SqlClient.SqlConnection.Open() JokePoint.Catalog.GetDepartments() in C:\MyCommerceSite\JokePoint\BusinessObjects\Catalog.vb:17 JokePoint.DepartmentsList.Page_Load(Object sender, EventArgs e) in C:\MyCommerceSite\JokePoint\UserControls\DepartmentsList.ascx.vb:44 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Control.LoadRecursive() System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain()

The connection tests ok in Visual Studio 2003. All permissions are set using SQL Management Studio Express 2005.

The book is using SQL 2000, I have been trying different connection syntax's in the Web.Config file all day and now I have a big headache. I know its something simple, can anyone please advise ?

Thanks in advance.

Mark

cracken:

<addkey="ConnectionString"value="Server=(local)\NetSDK;Integrated Security=True;Initial Catalog=JokePoint"/>

First, you are trying to connect using windows authentication and not with a SQL Server user credentials. I think the Integrated Security part is causing you the error. Have you tried to connect using SQL Server user credentials ( if any ), or you are using the windows authentication only.

Hope this will help.

|||

Try this...

web.config file:

<connectionStrings>

<addname="ConnectionString";Data Source=(local)\NetSDK;Integrated Security=True;Initial Catalog=JokePoint";

providerName="System.Data.SqlClient" />

</connectionStrings>

after that in the vb page:

Dim sepAsNew SqlConnection("connectionstring")

sep.Open()

Dim commandAsNew SqlCommand("GetDepartments", sep)

command.CommandType = CommandType.StoredProcedure

|||

Hi

Thanks for answering so quick, I am using Windows Integrated Secuity at the moment.

I have tried the suggestion above, but they were not sucessful. What I have done is changed the provier to OleDb and added a bit to the connection string.

I do not seen to get any code errors now, just login errors.

The VB file now looks like:

Imports System.Data

Imports System.Data.OleDb.OleDbConnection

Public Class Catalog

Public Shared Function GetDepartments() As OleDb.OleDbDataReader

'Create the connection object

Dim connection As New OleDb.OleDbConnection(connectionString)

'Create and initialize the command object

Dim command As New OleDb.OleDbCommand("GetDepartments", connection)

command.CommandType = CommandType.StoredProcedure

'Open the connection

connection.Open()

'Return a OleDbDataReader to the calling function

Return command.ExecuteReader(CommandBehavior.CloseConnection)

End Function

Private Shared ReadOnly Property connectionString() As String

Get

Return ConfigurationSettings.AppSettings("ConnectionString")

End Get

End Property

End Class

And the Web.Config connection string :

<configuration>

<appSettings>

<addkey="connectionString"value="Server=(local)\NetSDK; Provider=SQLOLEDB; Integrated Security=SSPI; Initial Catalog=JokePoint"/>

</appSettings>

And the error message :

Cannot open database "JokePoint" requested by the login. The login failed.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.OleDb.OleDbException: Cannot open database "JokePoint" requested by the login. The login failed.

Source Error:

Line 16: 'Open the connectionLine 17:Line 18: connection.Open()Line 19: Line 20: 'Return a OleDbDataReader to the calling function

All access accounts and read / write permission are correct.

Any more advise would be much app.

Regards

Mark

Tuesday, March 20, 2012

Connecting to remote database?

I am using SQL Server 2000 database in my VB.Net project.

My VB.net application is installed one two machines in different cities i.e. there are two separate databases.

First machine's IP address is say 202.33.44.55 and other machine IP address is say 203.33.55.66. Now I want to use each others databases i.e. I want to set their database group.

So that in my VB.Net's application which is installed on 202.33.44.55 I could see data of the 203.33.55.66 by just changing the connection string

You can include both connection strings in the web.config and then change the data source via dynamic code.

This method works well when there are applications running on the server with each using a different data source.

The web.config might look like this:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<clear />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=servername;Initial Catalog=database;User ID=user;Password=password;" providerName="System.Data.SqlClient" />
<remove name="ConnectionString1"/>
<add name="ConnectionString1" connectionString="Data Source=servername1;Initial Catalog=database1;User ID=user;Password=password;" providerName="System.Data.SqlClient" />
<remove name="ConnectionString2"/>
<add name="ConnectionString2" connectionString="Data Source=servername2;Initial Catalog=database2;User ID=user;Password=password;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

|||

harshal_shravgi:

I am using SQL Server 2000 database in my VB.Net project.

My VB.net application is installed one two machines in different cities i.e. there are two separate databases.

First machine's IP address is say 202.33.44.55 and other machine IP address is say 203.33.55.66. Now I want to use each others databases i.e. I want to set their database group.

So that in my VB.Net's application which is installed on 202.33.44.55 I could see data of the 203.33.55.66 by just changing the connection string

There is nothing dynamic in this Asp.net needs an account in the second server which should be added to SQL Server and the database, so you need to create a Windows account for Asp.net in the second server and grant that account permissions to SQL Server and the database. Hope this helps.

|||

Actually I want to set their database groups and as I said those two machines are not in my LAN. Those two machines are in different cities.

When I try setup a new sql group then I cann't see 203.33.55.66 from 202.33.44.55.

Above two IP addresses will be live IP address.

|||

harshal_shravgi:

Actually I want to set their database groups and as I said those two machines are not in my LAN. Those two machines are in different cities.

When I try setup a new sql group then I cann't see 203.33.55.66 from 202.33.44.55.

Above two IP addresses will be live IP address.

I have told you what you need to do location is not relevant if you do it your application will run, some of these security issues are created by developers who thinks database servers should let their application run without valid permissions.

|||

In my code I am using following connection string -

Provider=SQLOLEDB.1;Data Source=202.33.44.55;Initial Catalog= SLV2;UserId=sa;Password=;

It gives error that database does not exist.

What should I give datasource that database does not exist on my machine i.e. 203.33.55.66? And as I said when I tried to setup a new group in SQL Server then its not showing me that other machine database.

So I think its not the issue of coding, firstly I should be able set a group of databases in SQL Server then only I will be able to use it in my code.

|||

Hi,

You also need to check if the SQL Server instance you're connecting to is the default instance on 203.33.55.66. Is the instance on the default port 1433?

Please also check if the database named SLV2 exists on that machine and if sa with no password is a valid user name.

You can test this with SQL Server management studio or with a UDL file. Here are the steps creating a UDL file.

1. Create a text file on your desktop and rename it to XXX.udl
2. Double click on the file and a Data Link Property dialog box will be shown.
3. Setup the connection and use Test Connection button to test it.

HTH.

|||

Exactly when I tried to connect using .UDL file I didn't found that other machine.

So what to do now?

|||

harshal_shravgi:

Exactly when I tried to connect using .UDL file I didn't found that other machine.

So what to do now?

You need to create a domain account for Asp.net then grant that account permissions in SQL Server and database, sa is not a Windows account.

http://support.microsoft.com/kb/328306

|||

Hi,

And you can also connect to the database using SQL authentication. But the server should enable SQL authentication first.

HTH.

Thursday, March 8, 2012

Connecting to an Oracle Databse Server using SQL Express

Hello everyone,

I am working on a project for a professor. The project entails

designing and creating a database.We

were given individual space on the schools database server and we were given

SSH secure shell to connect and manage our respective databases.I took it upon myself to try out SQL Server

Express.Using the management studio I

am trying to connect to my school database and can’t seem to figure it

out.Can someone please give a noob some

simple and quick instructions on how to achieve this?

Thank you,

Your Friendly Neighborhood Programmer,

This is the SSH product in case any one was interested, ftp://ftp.ssh.com/pub/ssh/SSHSecureShellClient-3.2.9.exe

The title of your post is a little confusing. SQL Server Express Management tools don't connect to Oracle directly, unless you use an OPENQUERY statement or create a linked server. You can read more about those topics in Books Online. For more basic information on connecting to a database, check here:

http://msdn2.microsoft.com/en-us/library/ms345332.aspx

Microsoft also puts out a complete training series for free on Express:

http://msdn.microsoft.com/vstudio/express/sql/learning/default.aspx

Buck Woody

Connecting to an Oracle Databse Server using SQL Express

Hello everyone,

I am working on a project for a professor. The project entails

designing and creating a database.We

were given individual space on the schools database server and we were given

SSH secure shell to connect and manage our respective databases.I took it upon myself to try out SQL Server

Express.Using the management studio I

am trying to connect to my school database and can’t seem to figure it

out.Can someone please give a noob some

simple and quick instructions on how to achieve this?

Thank you,

Your Friendly Neighborhood Programmer,

This is the SSH product in case any one was interested, ftp://ftp.ssh.com/pub/ssh/SSHSecureShellClient-3.2.9.exe

The title of your post is a little confusing. SQL Server Express Management tools don't connect to Oracle directly, unless you use an OPENQUERY statement or create a linked server. You can read more about those topics in Books Online. For more basic information on connecting to a database, check here:

http://msdn2.microsoft.com/en-us/library/ms345332.aspx

Microsoft also puts out a complete training series for free on Express:

http://msdn.microsoft.com/vstudio/express/sql/learning/default.aspx

Buck Woody

Saturday, February 25, 2012

Connecting tables from a different database to an application

I have an application using an Access 2003 project connecting through ADO
which must refer to a table in a SQLServer 2000 database other than the main
database. When I connect, I get the data but the recordset is not updatable.
I can create a view in the main SQLServer database that makes the connection
and can be updated, but when I open that view in Access, it's still not
updatable.
Is there some simple way to update the data?
Hi,
http://support.microsoft.com/kb/328828
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
"TLD" <TLD@.discussions.microsoft.com> wrote in message
news:D6D862E7-D3AB-48EA-92D2-2479620DC822@.microsoft.com...
>I have an application using an Access 2003 project connecting through ADO
> which must refer to a table in a SQLServer 2000 database other than the
> main
> database. When I connect, I get the data but the recordset is not
> updatable.
> I can create a view in the main SQLServer database that makes the
> connection
> and can be updated, but when I open that view in Access, it's still not
> updatable.
> Is there some simple way to update the data?
>
|||Thanks for your help, but I don't see the answer to my problem in the article
referenced.
"Jens K. Suessmeyer" wrote:

> Hi,
> http://support.microsoft.com/kb/328828
>
> HTH, Jens K. Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "TLD" <TLD@.discussions.microsoft.com> wrote in message
> news:D6D862E7-D3AB-48EA-92D2-2479620DC822@.microsoft.com...
>
|||The problem turned out to be that the "uneditiable" fields were char rather
than varchar. When the user put a cursor into the field, he wasn't able to
insert letters. Changing the configuration of the underlying table has
resolved the problem.
Thanks for your help.
"Jens K. Suessmeyer" wrote:

> Hi,
> http://support.microsoft.com/kb/328828
>
> HTH, Jens K. Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "TLD" <TLD@.discussions.microsoft.com> wrote in message
> news:D6D862E7-D3AB-48EA-92D2-2479620DC822@.microsoft.com...
>

Connecting sql server with asp.net


i have created an asp.net application with sql server2000 as backend in my localsystem.

when i deployed the project in other sytem in network,
i receive the following error message.
"sql server does not exsist or access denied"
when i create the same database in local system and change the data source name with local system in configuration file, the application is working.

i do not face this problem with vb.net application as it takes its datasource from network system.

is there anything like i have to give permission for asp.net in sql server network utility.

can anyone sort out the problem

tell me the connection string ?

|||

i have sorted out this issue.

The solution is go to secuity create a new login and give permission to remote server.