Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Thursday, March 29, 2012

Separate Webserver and SQL Server -- error when connecting asp.net app to a datab

"Ann Marinas" <ka_marinas@dotnet.itags.org.xtra.co.nz> wrote in message
news:O8EQVObPFHA.2604@dotnet.itags.org.TK2MSFTNGP10.phx.gbl...

> Please help! I would really appreciate it!!
1) Are you using the native .NET data provider, OleDb or (surely not!) ODBC?
2) What ConnectionString are you using?
3) When you installed SQL Server, what authentication mode did you choose
(SQL Server, Windows or mixed)?
4) On the SQL Server machine, launch SQL Query Analyzer (NOT ENTERPRISE
MANAGER!) and try to log in using the UserID and password from the
ConnectionString in 2) above - can you? If so, can you drop the database
dropdown and select the database from the ConnectionString in 2) above? If
so, run SELECT * FROM sysobjects - what do you see?"Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
news:erPYsrbPFHA.3336@.TK2MSFTNGP09.phx.gbl...
Ann,

> 1) I am using System.Data.SqlClient for my data access.
That's a good thing.

> 2) I have changed the connection string which was located in my web.config
> file when we separated the webserver to the sql db server
I'm sure you have but, if we're going to help you, you're going to have to
tell us what the ConnectionString is... :-)

> 3) The authenticatio is set to Mixed mode -- SQL Server and Windows
> Authentication
Even easier.

> 4) On the Webserver, the Query Analyzer is not installed on the webserver.
> However if I am going to access the query analyzer, I have to access the
> sql server itself.
No - just use any machine which can "see" the SQL Server and which has the
SQL Client Tools installed.

Separate Webserver and SQL Server -- error when connecting asp.net

Hi all,
I would like to ask for some help regarding separating the asp.net
webserver and the sql server.
I have created an asp.net application for a certain company. Initially,
we installed both the iis and sql server in a single machine. Not too
long ago, the machine had some hardware problems, and management has
decided to purchase new servers, for both asp.net and sql server.
Once we installed my webapp on the first server and the sql server on
another, we have encountered some errors with it. Basically, the
exception that keeps on saying was:
"SQL Server database does not exist or access denied."
Tried creating a windows account for the webapp to use to connect and
configure it to the sql server, but it does not work.
Tried also connecting with the database using a SQL Server account, but
to no avail.
Please help! I would really appreciate it!!
Regards,
Ann MarinasHi, Wessel!
Thank you for your reply.
I've changed my connectionstring property after the database was
transfered to another server and it has got all the correct values, but
still no avail.
Thanks again for helping me out! Really do appreciate it!
Cheers,
Ann
Wessel Troost wrote:
> An ASP.NET application typically connects to the database through a
> System.Data.SqlClient.SqlConnection object.
> To change the SQL server, you need to find all SqlConnection objects and
> update their ConnectionString property to point to the new database
> server.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:11 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Subject: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company. Initially,
> we installed both the iis and sql server in a single machine. Not too
> long ago, the machine had some hardware problems, and management has
> decided to purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the
> exception that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account, but
> to no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
>
Hi, Mark!
Thank you for helping me out.
1) I am using System.Data.SqlClient for my data access.
2) I have changed the connection string which was located in my
web.config file when we separated the webserver to the sql db server
3) The authenticatio is set to Mixed mode -- SQL Server and Windows
Authentication
4) On the Webserver, the Query Analyzer is not installed on the
webserver. However if I am going to access the query analyzer, I have to
access the sql server itself.
Thanks again!
Mark Rae wrote:
> "Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
> news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
>
>
> 1) Are you using the native .NET data provider, OleDb or (surely not!) ODB
C?
> 2) What ConnectionString are you using?
> 3) When you installed SQL Server, what authentication mode did you choose
> (SQL Server, Windows or mixed)?
> 4) On the SQL Server machine, launch SQL Query Analyzer (NOT ENTERPRISE
> MANAGER!) and try to log in using the UserID and password from the
> ConnectionString in 2) above - can you? If so, can you drop the database
> dropdown and select the database from the ConnectionString in 2) above? If
> so, run SELECT * FROM sysobjects - what do you see?
>

Separate Webserver and SQL Server -- error when connecting asp.netapp to a database

Hi all,

I would like to ask for some help regarding separating the asp.net
webserver and the sql server.

I have created an asp.net application for a certain company. Initially,
we installed both the iis and sql server in a single machine. Not too
long ago, the machine had some hardware problems, and management has
decided to purchase new servers, for both asp.net and sql server.

Once we installed my webapp on the first server and the sql server on
another, we have encountered some errors with it. Basically, the
exception that keeps on saying was:

"SQL Server database does not exist or access denied."

Tried creating a windows account for the webapp to use to connect and
configure it to the sql server, but it does not work.

Tried also connecting with the database using a SQL Server account, but
to no avail.

Please help! I would really appreciate it!!

Regards,
Ann MarinasAn ASP.NET application typically connects to the database through a
System.Data.SqlClient.SqlConnection object.
To change the SQL server, you need to find all SqlConnection objects and
update their ConnectionString property to point to the new database
server.

Greetings,
Wessel

--Original Message--
From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
Posted At: Sunday, April 10, 2005 12:11 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database
Subject: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database

Hi all,

I would like to ask for some help regarding separating the asp.net
webserver and the sql server.

I have created an asp.net application for a certain company. Initially,
we installed both the iis and sql server in a single machine. Not too
long ago, the machine had some hardware problems, and management has
decided to purchase new servers, for both asp.net and sql server.

Once we installed my webapp on the first server and the sql server on
another, we have encountered some errors with it. Basically, the
exception that keeps on saying was:

"SQL Server database does not exist or access denied."

Tried creating a windows account for the webapp to use to connect and
configure it to the sql server, but it does not work.

Tried also connecting with the database using a SQL Server account, but
to no avail.

Please help! I would really appreciate it!!

Regards,
Ann Marinas
"Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...

> Please help! I would really appreciate it!!

1) Are you using the native .NET data provider, OleDb or (surely not!) ODBC?

2) What ConnectionString are you using?

3) When you installed SQL Server, what authentication mode did you choose
(SQL Server, Windows or mixed)?

4) On the SQL Server machine, launch SQL Query Analyzer (NOT ENTERPRISE
MANAGER!) and try to log in using the UserID and password from the
ConnectionString in 2) above - can you? If so, can you drop the database
dropdown and select the database from the ConnectionString in 2) above? If
so, run SELECT * FROM sysobjects - what do you see?
Hi, Wessel!

Thank you for your reply.

I've changed my connectionstring property after the database was
transfered to another server and it has got all the correct values, but
still no avail.

Thanks again for helping me out! Really do appreciate it!

Cheers,
Ann

Wessel Troost wrote:
> An ASP.NET application typically connects to the database through a
> System.Data.SqlClient.SqlConnection object.
> To change the SQL server, you need to find all SqlConnection objects and
> update their ConnectionString property to point to the new database
> server.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:11 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Subject: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company. Initially,
> we installed both the iis and sql server in a single machine. Not too
> long ago, the machine had some hardware problems, and management has
> decided to purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the
> exception that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account, but
> to no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
Hi, Mark!

Thank you for helping me out.

1) I am using System.Data.SqlClient for my data access.
2) I have changed the connection string which was located in my
web.config file when we separated the webserver to the sql db server
3) The authenticatio is set to Mixed mode -- SQL Server and Windows
Authentication
4) On the Webserver, the Query Analyzer is not installed on the
webserver. However if I am going to access the query analyzer, I have to
access the sql server itself.

Thanks again!

Mark Rae wrote:
> "Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
> news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
>
>>Please help! I would really appreciate it!!
>
> 1) Are you using the native .NET data provider, OleDb or (surely not!) ODBC?
> 2) What ConnectionString are you using?
> 3) When you installed SQL Server, what authentication mode did you choose
> (SQL Server, Windows or mixed)?
> 4) On the SQL Server machine, launch SQL Query Analyzer (NOT ENTERPRISE
> MANAGER!) and try to log in using the UserID and password from the
> ConnectionString in 2) above - can you? If so, can you drop the database
> dropdown and select the database from the ConnectionString in 2) above? If
> so, run SELECT * FROM sysobjects - what do you see?
>
- Post the connection string, we might be able to help.
- "telnet sqlserver 1433" to see if you can reach the SQL server. 1433
is the default SQL server port.
- Check the firewall settings on the SQL Server.
- Check if the SQL Server user has a default database, and if the user
is valid in that database.

Greetings,
Wessel

--Original Message--
From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
Posted At: Sunday, April 10, 2005 12:55 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database
Subject: Re: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database

Hi, Wessel!

Thank you for your reply.

I've changed my connectionstring property after the database was
transfered to another server and it has got all the correct values, but
still no avail.

Thanks again for helping me out! Really do appreciate it!

Cheers,
Ann

Wessel Troost wrote:
> An ASP.NET application typically connects to the database through a
> System.Data.SqlClient.SqlConnection object.
> To change the SQL server, you need to find all SqlConnection objects
and
> update their ConnectionString property to point to the new database
> server.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:11 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when
connecting
> asp.net app to a database
> Subject: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company.
Initially,
> we installed both the iis and sql server in a single machine. Not too
> long ago, the machine had some hardware problems, and management has
> decided to purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the
> exception that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account,
but
> to no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
"Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
news:erPYsrbPFHA.3336@.TK2MSFTNGP09.phx.gbl...

Ann,

> 1) I am using System.Data.SqlClient for my data access.

That's a good thing.

> 2) I have changed the connection string which was located in my web.config
> file when we separated the webserver to the sql db server

I'm sure you have but, if we're going to help you, you're going to have to
tell us what the ConnectionString is... :-)

> 3) The authenticatio is set to Mixed mode -- SQL Server and Windows
> Authentication

Even easier.

> 4) On the Webserver, the Query Analyzer is not installed on the webserver.
> However if I am going to access the query analyzer, I have to access the
> sql server itself.

No - just use any machine which can "see" the SQL Server and which has the
SQL Client Tools installed.
Ann,

You are getting an error in accessing database. This means that server
connections is ok, just database is not accessible. Most likely you have to
have another look into permissions for the login you are connecting under
for the database you are connecting to. Or make sure the database name is
correct.

Eliyahu

"Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company. Initially,
> we installed both the iis and sql server in a single machine. Not too
> long ago, the machine had some hardware problems, and management has
> decided to purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the
> exception that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account, but
> to no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas
the connection string is:

Data Provider=myDB; Initial Catalog=myDBName; Integrated Securit=SSPI

tried doing the telnet, and it says:
Connecting To database...Could not open a connection to host on port 1433 :
Connect failed

Really do appreciate your help!

"Wessel Troost" wrote:

> - Post the connection string, we might be able to help.
> - "telnet sqlserver 1433" to see if you can reach the SQL server. 1433
> is the default SQL server port.
> - Check the firewall settings on the SQL Server.
> - Check if the SQL Server user has a default database, and if the user
> is valid in that database.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:55 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Subject: Re: Separate Webserver and SQL Server -- error when connecting
> asp.net app to a database
> Hi, Wessel!
> Thank you for your reply.
> I've changed my connectionstring property after the database was
> transfered to another server and it has got all the correct values, but
> still no avail.
> Thanks again for helping me out! Really do appreciate it!
> Cheers,
> Ann
> Wessel Troost wrote:
> > An ASP.NET application typically connects to the database through a
> > System.Data.SqlClient.SqlConnection object.
> > To change the SQL server, you need to find all SqlConnection objects
> and
> > update their ConnectionString property to point to the new database
> > server.
> > Greetings,
> > Wessel
> > --Original Message--
> > From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> > Posted At: Sunday, April 10, 2005 12:11 PM
> > Posted To: microsoft.public.dotnet.framework.aspnet
> > Conversation: Separate Webserver and SQL Server -- error when
> connecting
> > asp.net app to a database
> > Subject: Separate Webserver and SQL Server -- error when connecting
> > asp.net app to a database
> > Hi all,
> > I would like to ask for some help regarding separating the asp.net
> > webserver and the sql server.
> > I have created an asp.net application for a certain company.
> Initially,
> > we installed both the iis and sql server in a single machine. Not too
> > long ago, the machine had some hardware problems, and management has
> > decided to purchase new servers, for both asp.net and sql server.
> > Once we installed my webapp on the first server and the sql server on
> > another, we have encountered some errors with it. Basically, the
> > exception that keeps on saying was:
> > "SQL Server database does not exist or access denied."
> > Tried creating a windows account for the webapp to use to connect and
> > configure it to the sql server, but it does not work.
> > Tried also connecting with the database using a SQL Server account,
> but
> > to no avail.
> > Please help! I would really appreciate it!!
> > Regards,
> > Ann Marinas
>
Hi, Eliyahu!

I've checked the name of the database and the windows user access name that
will be used for the database connection. Before I did that, I've double-
checked as well the user account that will be used to impersonate the access
if it has permissions on the SQL Server database, but to no avail.

It keeps on saying that the db is not existing or access is denied -- in
which I could clearly see the database on the database folder.

Thanks for helping me out! Really appreciate it! :)
"Eliyahu Goldin" wrote:

> Ann,
> You are getting an error in accessing database. This means that server
> connections is ok, just database is not accessible. Most likely you have to
> have another look into permissions for the login you are connecting under
> for the database you are connecting to. Or make sure the database name is
> correct.
> Eliyahu
> "Ann Marinas" <ka_marinas@.xtra.co.nz> wrote in message
> news:O8EQVObPFHA.2604@.TK2MSFTNGP10.phx.gbl...
> > Hi all,
> > I would like to ask for some help regarding separating the asp.net
> > webserver and the sql server.
> > I have created an asp.net application for a certain company. Initially,
> > we installed both the iis and sql server in a single machine. Not too
> > long ago, the machine had some hardware problems, and management has
> > decided to purchase new servers, for both asp.net and sql server.
> > Once we installed my webapp on the first server and the sql server on
> > another, we have encountered some errors with it. Basically, the
> > exception that keeps on saying was:
> > "SQL Server database does not exist or access denied."
> > Tried creating a windows account for the webapp to use to connect and
> > configure it to the sql server, but it does not work.
> > Tried also connecting with the database using a SQL Server account, but
> > to no avail.
> > Please help! I would really appreciate it!!
> > Regards,
> > Ann Marinas
>
Hi Ann,

Looks like there's more than one issue. I think a connection string for
SQL server looks like this:

data source=...;user id=...;password=...;initial catalog=...;

The data provider is the driver that serves your database, not the
database.

Below this, on the network layer, there's no chance your connection is
going to work if you can't connect to the database server on port 1433.

Greetings,
Wessel

--Original Message--
From: Ann Marinas [mailto:Ann Marinas@.discussions.microsoft.com]
Posted At: Sunday, April 10, 2005 11:15 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Separate Webserver and SQL Server -- error when connecting
asp.net app to a database
Subject: Re: Separate Webserver and SQL Server -- error when connecting
asp

the connection string is:

Data Provider=myDB; Initial Catalog=myDBName; Integrated Securit=SSPI

tried doing the telnet, and it says:
Connecting To database...Could not open a connection to host on port
1433 :
Connect failed

Really do appreciate your help!

"Wessel Troost" wrote:

> - Post the connection string, we might be able to help.
> - "telnet sqlserver 1433" to see if you can reach the SQL server. 1433
> is the default SQL server port.
> - Check the firewall settings on the SQL Server.
> - Check if the SQL Server user has a default database, and if the user
> is valid in that database.
> Greetings,
> Wessel
> --Original Message--
> From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> Posted At: Sunday, April 10, 2005 12:55 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: Separate Webserver and SQL Server -- error when
connecting
> asp.net app to a database
> Subject: Re: Separate Webserver and SQL Server -- error when
connecting
> asp.net app to a database
> Hi, Wessel!
> Thank you for your reply.
> I've changed my connectionstring property after the database was
> transfered to another server and it has got all the correct values,
but
> still no avail.
> Thanks again for helping me out! Really do appreciate it!
> Cheers,
> Ann
> Wessel Troost wrote:
> > An ASP.NET application typically connects to the database through a
> > System.Data.SqlClient.SqlConnection object.
> > To change the SQL server, you need to find all SqlConnection objects
> and
> > update their ConnectionString property to point to the new database
> > server.
> > Greetings,
> > Wessel
> > --Original Message--
> > From: Ann Marinas [mailto:ka_marinas@.xtra.co.nz]
> > Posted At: Sunday, April 10, 2005 12:11 PM
> > Posted To: microsoft.public.dotnet.framework.aspnet
> > Conversation: Separate Webserver and SQL Server -- error when
> connecting
> > asp.net app to a database
> > Subject: Separate Webserver and SQL Server -- error when connecting
> > asp.net app to a database
> > Hi all,
> > I would like to ask for some help regarding separating the asp.net
> > webserver and the sql server.
> > I have created an asp.net application for a certain company.
> Initially,
> > we installed both the iis and sql server in a single machine. Not
too
> > long ago, the machine had some hardware problems, and management has

> > decided to purchase new servers, for both asp.net and sql server.
> > Once we installed my webapp on the first server and the sql server
on
> > another, we have encountered some errors with it. Basically, the
> > exception that keeps on saying was:
> > "SQL Server database does not exist or access denied."
> > Tried creating a windows account for the webapp to use to connect
and
> > configure it to the sql server, but it does not work.
> > Tried also connecting with the database using a SQL Server account,
> but
> > to no avail.
> > Please help! I would really appreciate it!!
> > Regards,
> > Ann Marinas
http://support.microsoft.com/kb/827422

John Webb
One of my developers had the same problem and I fixed it by changing the
identity with which ASP.NET
process was running that web-application. Add the following section to your
application's web.config file:
<system.web>
<identity impersonate="true" userName="someaccount" password="something"
/>
</system.web
Note that provided windows user account must have granted required
permissions to access the remote database.

I also tried something else which worked but this one was more preferred. I
will be pleased if you let me know other solutions you may find.

Jamal

-- Original Message --
From: "Ann Marinas" <ka_marinas@.xtra.co.nz>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Sent: Sunday, April 10, 2005 2:41 PM
Subject: Separate Webserver and SQL Server -- error when connecting asp.net
app to a database

> Hi all,
> I would like to ask for some help regarding separating the asp.net
> webserver and the sql server.
> I have created an asp.net application for a certain company. Initially, we
> installed both the iis and sql server in a single machine. Not too long
> ago, the machine had some hardware problems, and management has decided to
> purchase new servers, for both asp.net and sql server.
> Once we installed my webapp on the first server and the sql server on
> another, we have encountered some errors with it. Basically, the exception
> that keeps on saying was:
> "SQL Server database does not exist or access denied."
> Tried creating a windows account for the webapp to use to connect and
> configure it to the sql server, but it does not work.
> Tried also connecting with the database using a SQL Server account, but to
> no avail.
> Please help! I would really appreciate it!!
>
> Regards,
> Ann Marinas

Monday, March 26, 2012

serializable class

Hi,

How do you make a class generated by the DataSet.xsd serializable? So I can store it in session with SQL Server?

Thanks.

You can mark the class as serilizable like this:

[Serializable]
public class MyClass

{

//Class code...

}


Thanks. But the class I am trying to Serialized is generated by DataSet.xsd, so I cannot do that.

I have tried to make a partial class but it does not work:

[Serializable]

public partial class DataSetXSDClassName {

}


OH! Sorry... I missed the part of the xsd... Can you post the class generated by it then?


I am not sure about that but you can do the followin work around.

Provided your generated class look like this:

public class A{public int id;public string titlepublic A(int aId,string aTitle) { id = aId; title = aTitle; }}//then you define class B like this:[Serializable]public class B{public int id;public string title;public B(A obj) { id = obj.id; title = obj.title; }}
after that you can serialize and deserialize instances of B class and then use their members/properties to create A object and further use it in your code. Other benefit of it is that you can serialize only the information that you need.


The class is not actually 'physical' that I can go and copy and paste the code, but if any error occur then it will show up in debug mode, but will a weird filename like like random string.

Also the 'work around' class does work, but that will generated a class 99% the same as the one from xsd file. Any changes in dataset.xsd means I manually have to do the same for this 'work around' class.

But thanks for the comment.

Saturday, March 24, 2012

Serialization of Session objects

Hello,
I have implemented SQL Server session state in my application however I am
having some problems. Simple objects stored in Session state are fine and ar
e
handled by .NET, however when I try to store more complex objects such as an
ArrayList in session state I am not able to figure out exactly what I have t
o
do to serialize and deserialize the object.
There doesn't seem to be any code examples around when it comes to
serializing session objects. Could anyone provide me with some code that
would help?
I have managed to successfully serialize and deserialize an object to a file
but I am specifically looking to serialize the object to session state.
Thanks,
GaryAny class stored in session must implement the ISerializable attribute.
http://msdn.microsoft.com/library/d.../>
asstopic.asp
Robbe Morris - 2004/2005 Microsoft MVP C#
Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp
"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
> are
> handled by .NET, however when I try to store more complex objects such as
> an
> ArrayList in session state I am not able to figure out exactly what I have
> to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
> file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Gary,
All you have to do is to put a line
[Serializable]
before definition of every class you are going to save in the session state.
Eliyahu
"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
are
> handled by .NET, however when I try to store more complex objects such as
an
> ArrayList in session state I am not able to figure out exactly what I have
to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Hello,
Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manuall
y
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!
Regards,
Gary
"Eliyahu Goldin" wrote:

> Gary,
> All you have to do is to put a line
> [Serializable]
> before definition of every class you are going to save in the session stat
e.
>
> Eliyahu
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> are
> an
> to
> file
>
>
Hello,
Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manuall
y
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!
Regards,
Gary
"Robbe Morris [C# MVP]" wrote:

> Any class stored in session must implement the ISerializable attribute.
> http://msdn.microsoft.com/library/d...
classtopic.asp
> --
> Robbe Morris - 2004/2005 Microsoft MVP C#
> Earn money answering .NET Framework
> messageboard posts at EggHeadCafe.com.
> http://www.eggheadcafe.com/forums/merit.asp
>
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
>
>

Serialization of Session objects

Hello,

I have implemented SQL Server session state in my application however I am
having some problems. Simple objects stored in Session state are fine and are
handled by .NET, however when I try to store more complex objects such as an
ArrayList in session state I am not able to figure out exactly what I have to
do to serialize and deserialize the object.

There doesn't seem to be any code examples around when it comes to
serializing session objects. Could anyone provide me with some code that
would help?

I have managed to successfully serialize and deserialize an object to a file
but I am specifically looking to serialize the object to session state.

Thanks,

GaryAny class stored in session must implement the ISerializable attribute.

http://msdn.microsoft.com/library/d...lasst opic.asp

--
Robbe Morris - 2004/2005 Microsoft MVP C#

Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp

"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
> are
> handled by .NET, however when I try to store more complex objects such as
> an
> ArrayList in session state I am not able to figure out exactly what I have
> to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
> file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Gary,

All you have to do is to put a line
[Serializable]

before definition of every class you are going to save in the session state.

Eliyahu

"Gary" <Gary@.discussions.microsoft.com> wrote in message
news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> Hello,
> I have implemented SQL Server session state in my application however I am
> having some problems. Simple objects stored in Session state are fine and
are
> handled by .NET, however when I try to store more complex objects such as
an
> ArrayList in session state I am not able to figure out exactly what I have
to
> do to serialize and deserialize the object.
> There doesn't seem to be any code examples around when it comes to
> serializing session objects. Could anyone provide me with some code that
> would help?
> I have managed to successfully serialize and deserialize an object to a
file
> but I am specifically looking to serialize the object to session state.
> Thanks,
> Gary
Hello,

Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manually
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!

Regards,

Gary

"Eliyahu Goldin" wrote:

> Gary,
> All you have to do is to put a line
> [Serializable]
> before definition of every class you are going to save in the session state.
>
> Eliyahu
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> > Hello,
> > I have implemented SQL Server session state in my application however I am
> > having some problems. Simple objects stored in Session state are fine and
> are
> > handled by .NET, however when I try to store more complex objects such as
> an
> > ArrayList in session state I am not able to figure out exactly what I have
> to
> > do to serialize and deserialize the object.
> > There doesn't seem to be any code examples around when it comes to
> > serializing session objects. Could anyone provide me with some code that
> > would help?
> > I have managed to successfully serialize and deserialize an object to a
> file
> > but I am specifically looking to serialize the object to session state.
> > Thanks,
> > Gary
>
Hello,

Thank you very much for your reply, adding the <Serializable()> attribute to
my class has resolved my problem. I actually thought that you had to manually
serialize the object and then put it in to the session object, I had no idea
that .NET handles this for you as long as the serialization attribute is
added. I have spent the best part of my day trying to figure this out so
thanks very much!

Regards,

Gary

"Robbe Morris [C# MVP]" wrote:

> Any class stored in session must implement the ISerializable attribute.
> http://msdn.microsoft.com/library/d...lasst opic.asp
> --
> Robbe Morris - 2004/2005 Microsoft MVP C#
> Earn money answering .NET Framework
> messageboard posts at EggHeadCafe.com.
> http://www.eggheadcafe.com/forums/merit.asp
>
> "Gary" <Gary@.discussions.microsoft.com> wrote in message
> news:1D664DFE-09DE-46BC-8703-46E108DCCA2B@.microsoft.com...
> > Hello,
> > I have implemented SQL Server session state in my application however I am
> > having some problems. Simple objects stored in Session state are fine and
> > are
> > handled by .NET, however when I try to store more complex objects such as
> > an
> > ArrayList in session state I am not able to figure out exactly what I have
> > to
> > do to serialize and deserialize the object.
> > There doesn't seem to be any code examples around when it comes to
> > serializing session objects. Could anyone provide me with some code that
> > would help?
> > I have managed to successfully serialize and deserialize an object to a
> > file
> > but I am specifically looking to serialize the object to session state.
> > Thanks,
> > Gary
>

serialize to SQL Server Blob instead of XML serialize

I've been experiencing problems on some computers with XML Serialization. On
some computers the files do not get created on the web server's hard drive
and it's been driving me nuts trying to figure it out.
I store navigation history and application state in object collections and
save this upon application exit by doing an XML.Serialize.
I'd like to serialize directly to SQL Server instead. Can I create a stream
object to be used by SQL Server with serialization?
ThanksYeah, this is the basics (DT is just an object I'm taking from session and
serializing):
Dim ms As New MemoryStream
ms = SerializeDT(CType(Session("DT"), DTProcess))
Dim da() As Byte
da = ms.ToArray
cmd.Parameters("@.DesktopData").Value = da
SqlConnection1.Open()
cmd.ExecuteNonQuery()
SqlConnection1.Close()
Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
MemoryStream
Dim ms As New MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(ms, DTSource)
ms.Position = 0
Return ms
End Function
-John Oakes
"Gordz" <joeblow@.aol.com> wrote in message
news:10c96ar3sr73f4@.corp.supernews.com...
> I've been experiencing problems on some computers with XML Serialization.
On
> some computers the files do not get created on the web server's hard drive
> and it's been driving me nuts trying to figure it out.
> I store navigation history and application state in object collections and
> save this upon application exit by doing an XML.Serialize.
> I'd like to serialize directly to SQL Server instead. Can I create a
stream
> object to be used by SQL Server with serialization?
> Thanks
>
thanks John.
I've never used binary objects in SQL before.
Where exactly is your data "@.DesktopData" stored in the database? Do you
have a field already defined?
Cheers,
Gord
"John Oakes" <john@.nospam.networkproductions.net> wrote in message
news:OwaYP%23KTEHA.1416@.TK2MSFTNGP12.phx.gbl...
Yeah, this is the basics (DT is just an object I'm taking from session and
serializing):
Dim ms As New MemoryStream
ms = SerializeDT(CType(Session("DT"), DTProcess))
Dim da() As Byte
da = ms.ToArray
cmd.Parameters("@.DesktopData").Value = da
SqlConnection1.Open()
cmd.ExecuteNonQuery()
SqlConnection1.Close()
Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
MemoryStream
Dim ms As New MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(ms, DTSource)
ms.Position = 0
Return ms
End Function
-John Oakes
"Gordz" <joeblow@.aol.com> wrote in message
news:10c96ar3sr73f4@.corp.supernews.com...
> I've been experiencing problems on some computers with XML Serialization.
On
> some computers the files do not get created on the web server's hard drive
> and it's been driving me nuts trying to figure it out.
> I store navigation history and application state in object collections and
> save this upon application exit by doing an XML.Serialize.
> I'd like to serialize directly to SQL Server instead. Can I create a
stream
> object to be used by SQL Server with serialization?
> Thanks
>
Yes, I have a field defined. The datatype is image, which is
variable-length binary data from 0 through 231-1 (2,147,483,647) bytes.
-John Oakes
"Gordz" <joeblow@.aol.com> wrote in message
news:10c9fasr23jm702@.corp.supernews.com...
> thanks John.
> I've never used binary objects in SQL before.
> Where exactly is your data "@.DesktopData" stored in the database? Do you
> have a field already defined?
> Cheers,
> Gord
> "John Oakes" <john@.nospam.networkproductions.net> wrote in message
> news:OwaYP%23KTEHA.1416@.TK2MSFTNGP12.phx.gbl...
> Yeah, this is the basics (DT is just an object I'm taking from session and
> serializing):
> Dim ms As New MemoryStream
> ms = SerializeDT(CType(Session("DT"), DTProcess))
> Dim da() As Byte
> da = ms.ToArray
> cmd.Parameters("@.DesktopData").Value = da
> SqlConnection1.Open()
> cmd.ExecuteNonQuery()
> SqlConnection1.Close()
> Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
> MemoryStream
> Dim ms As New MemoryStream
> Dim formatter As New BinaryFormatter
> formatter.Serialize(ms, DTSource)
> ms.Position = 0
> Return ms
> End Function
> -John Oakes
>
> "Gordz" <joeblow@.aol.com> wrote in message
> news:10c96ar3sr73f4@.corp.supernews.com...
Serialization.
> On
drive
and
> stream
>
>

serialize to SQL Server Blob instead of XML serialize

I've been experiencing problems on some computers with XML Serialization. On
some computers the files do not get created on the web server's hard drive
and it's been driving me nuts trying to figure it out.

I store navigation history and application state in object collections and
save this upon application exit by doing an XML.Serialize.

I'd like to serialize directly to SQL Server instead. Can I create a stream
object to be used by SQL Server with serialization?

ThanksYeah, this is the basics (DT is just an object I'm taking from session and
serializing):

Dim ms As New MemoryStream
ms = SerializeDT(CType(Session("DT"), DTProcess))
Dim da() As Byte
da = ms.ToArray
cmd.Parameters("@.DesktopData").Value = da
SqlConnection1.Open()
cmd.ExecuteNonQuery()
SqlConnection1.Close()

Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
MemoryStream
Dim ms As New MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(ms, DTSource)
ms.Position = 0
Return ms
End Function

-John Oakes

"Gordz" <joeblow@.aol.com> wrote in message
news:10c96ar3sr73f4@.corp.supernews.com...
> I've been experiencing problems on some computers with XML Serialization.
On
> some computers the files do not get created on the web server's hard drive
> and it's been driving me nuts trying to figure it out.
> I store navigation history and application state in object collections and
> save this upon application exit by doing an XML.Serialize.
> I'd like to serialize directly to SQL Server instead. Can I create a
stream
> object to be used by SQL Server with serialization?
> Thanks
thanks John.

I've never used binary objects in SQL before.

Where exactly is your data "@.DesktopData" stored in the database? Do you
have a field already defined?

Cheers,

Gord

"John Oakes" <john@.nospam.networkproductions.net> wrote in message
news:OwaYP%23KTEHA.1416@.TK2MSFTNGP12.phx.gbl...
Yeah, this is the basics (DT is just an object I'm taking from session and
serializing):

Dim ms As New MemoryStream
ms = SerializeDT(CType(Session("DT"), DTProcess))
Dim da() As Byte
da = ms.ToArray
cmd.Parameters("@.DesktopData").Value = da
SqlConnection1.Open()
cmd.ExecuteNonQuery()
SqlConnection1.Close()

Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
MemoryStream
Dim ms As New MemoryStream
Dim formatter As New BinaryFormatter
formatter.Serialize(ms, DTSource)
ms.Position = 0
Return ms
End Function

-John Oakes

"Gordz" <joeblow@.aol.com> wrote in message
news:10c96ar3sr73f4@.corp.supernews.com...
> I've been experiencing problems on some computers with XML Serialization.
On
> some computers the files do not get created on the web server's hard drive
> and it's been driving me nuts trying to figure it out.
> I store navigation history and application state in object collections and
> save this upon application exit by doing an XML.Serialize.
> I'd like to serialize directly to SQL Server instead. Can I create a
stream
> object to be used by SQL Server with serialization?
> Thanks
Yes, I have a field defined. The datatype is image, which is
variable-length binary data from 0 through 231-1 (2,147,483,647) bytes.

-John Oakes

"Gordz" <joeblow@.aol.com> wrote in message
news:10c9fasr23jm702@.corp.supernews.com...
> thanks John.
> I've never used binary objects in SQL before.
> Where exactly is your data "@.DesktopData" stored in the database? Do you
> have a field already defined?
> Cheers,
> Gord
> "John Oakes" <john@.nospam.networkproductions.net> wrote in message
> news:OwaYP%23KTEHA.1416@.TK2MSFTNGP12.phx.gbl...
> Yeah, this is the basics (DT is just an object I'm taking from session and
> serializing):
> Dim ms As New MemoryStream
> ms = SerializeDT(CType(Session("DT"), DTProcess))
> Dim da() As Byte
> da = ms.ToArray
> cmd.Parameters("@.DesktopData").Value = da
> SqlConnection1.Open()
> cmd.ExecuteNonQuery()
> SqlConnection1.Close()
> Public Shared Function SerializeDT(ByVal DTSource As DTProcess) As
> MemoryStream
> Dim ms As New MemoryStream
> Dim formatter As New BinaryFormatter
> formatter.Serialize(ms, DTSource)
> ms.Position = 0
> Return ms
> End Function
> -John Oakes
>
> "Gordz" <joeblow@.aol.com> wrote in message
> news:10c96ar3sr73f4@.corp.supernews.com...
> > I've been experiencing problems on some computers with XML
Serialization.
> On
> > some computers the files do not get created on the web server's hard
drive
> > and it's been driving me nuts trying to figure it out.
> > I store navigation history and application state in object collections
and
> > save this upon application exit by doing an XML.Serialize.
> > I'd like to serialize directly to SQL Server instead. Can I create a
> stream
> > object to be used by SQL Server with serialization?
> > Thanks

Serialize/Send a recordset content through network

Hi, the scenario should be like this:
I have a "Server" application, and a UserControl running on an asp.net page.
The UserControl sends a SQL Query string via UDP to the Server (after some
sort of authentication, etc etc)
The Server Application executes the query on his local SQL2k server
The Server Application gets the recordset returned by query execution
Then the server application sends to the UserControl the recordset returned
by the query execution
Could this be done? Like using a sort of Serialization of the SQLDataReader?
Or should i use another tecnique?
My target is to avoid opening the SQLServer directly to the public internet,
but to redirect all the queryes to my application, using some sort of
authentication and encryption.
I'm nearly new to .net framework so i'm discovering new things every day.
Thanx a lot for the help, and for any link that will be useful
MarcoMarco:
The scenario you describe sounds very much like a case where you would use a
web service. Since web services already use XML and SOAP, you will have the
serialization in the format you require.
David Lloyd
MCSD .NET
http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"M. Simioni" <m.simioniREMOVETHIS@.TOCONTACTMEwooow.it> wrote in message
news:1RRee.7789$TR5.6704@.news.edisontel.com...
> Hi, the scenario should be like this:
> I have a "Server" application, and a UserControl running on an asp.net
page.
> The UserControl sends a SQL Query string via UDP to the Server (after some
> sort of authentication, etc etc)
> The Server Application executes the query on his local SQL2k server
> The Server Application gets the recordset returned by query execution
> Then the server application sends to the UserControl the recordset
returned
> by the query execution
> Could this be done? Like using a sort of Serialization of the
SQLDataReader?
> Or should i use another tecnique?
> My target is to avoid opening the SQLServer directly to the public
internet,
> but to redirect all the queryes to my application, using some sort of
> authentication and encryption.
> I'm nearly new to .net framework so i'm discovering new things every day.
> Thanx a lot for the help, and for any link that will be useful
> Marco
>
Well, i forgot to mention, but i also need to fire events from the server
application to the user control.
The goal of the server application isn't only to be a 'forwarder' of sql
query commands from clients to db, but also should fire events to client
when something happens (like packets received from the rs232 located on the
server).
I planned to use an exchange of UDP message between the 'server application'
and the user control to exchange events (from srvr -> client) and sql
queryes (from client->srvr). But i couldn't realize how to exchange sql
resulting recordsets.
Can i do this with web services too? or should i split the two tasks in
a) a server application that send udp messages to 'clients'
b) a web service that the 'clients' use to query the database
sorry for my bad english :)
Marco
"David Lloyd" <info@.LemingtonConsulting.com> ha scritto nel messaggio
news:ZNSee.3282$0i3.1968@.bignews3.bellsouth.net...
> Marco:
> The scenario you describe sounds very much like a case where you would use
> a
> web service. Since web services already use XML and SOAP, you will have
> the
> serialization in the format you require.
>
> --
> David Lloyd
> MCSD .NET
> http://LemingtonConsulting.com
> This response is supplied "as is" without any representations or
> warranties.
>
> "M. Simioni" <m.simioniREMOVETHIS@.TOCONTACTMEwooow.it> wrote in message
> news:1RRee.7789$TR5.6704@.news.edisontel.com...
> page.
> returned
> SQLDataReader?
> internet,
>
Marco,
You never can sent something to a client. Therefore is to much protected.
You can communicate with a client when he has on the other side a program
that accept what you sent.
I think as well that the suggestion from David can maybe be a good solution
for you. We can never see from this newsgroup if it real fits. Have a look
at this pages.
http://msdn.microsoft.com/library/d...r />
hrough.asp
I expect however as well, that trying to reach your goall with a recordset
can be much harder than using the ADONET components.
I hope this helps,
Cor

serialized binary files vs Sql Server Performance..

I'm considering deploying an application that will us an IP address locaiton
database provided by Ip2location.com...
http://www.ip2location.net/ip2locat...-component.aspx
their .net component reads data from a binary file. I'm guess i'm wondering
which of the two options would be best.
1) read data from the binary files (~27 mb or so)
2) or query a sql DB with the same info.
The database will have about 8 columns and ~ 1.8 millions rows.
i'm developing for a high traffic webisite, and i would like to query this
DB to get the City info from the DB when a visitor first visits the site
(based on their ip address).
Also, how do serialized binary files handle simultaneous file access? Would
a high traffic webisite be able to use a serialized file efficiently if the
file was read often?
Thanks!Fabuloussites wrote:
> I'm considering deploying an application that will us an IP address locait
on
> database provided by Ip2location.com...
> http://www.ip2location.net/ip2locat...-component.aspx
> their .net component reads data from a binary file. I'm guess i'm wonderi
ng
> which of the two options would be best.
> 1) read data from the binary files (~27 mb or so)
> 2) or query a sql DB with the same info.
> The database will have about 8 columns and ~ 1.8 millions rows.
> i'm developing for a high traffic webisite, and i would like to query this
> DB to get the City info from the DB when a visitor first visits the site
> (based on their ip address).
> Also, how do serialized binary files handle simultaneous file access? Wou
ld
> a high traffic webisite be able to use a serialized file efficiently if th
e
> file was read often?
> Thanks!
I don't see reading from a file as a big problem (open read-only), but
that's still a fair amount of data to parse (27MB). A database can
handle that much data easily (they can handle many GBs of data no
problem). Perhaps the best thing to do would be to benchmark both (like
say, query it 1000 times each ways and compare how much time it took)
and to do some load testing (not just 1 request after each other but
many simultaneous queries). My guess is that the results (which one
works best) will vary depending on how much traffic you have, the load
on the server as well as the load on the database server. It's hard to
predict accurately what would work best.
If you didn't need the city I'd recommend you have a look at this
article http://www.eggheadcafe.com/articles/20051109.asp which manages
to do it all in RAM (no file access or DB queries).
Actually,
you can get all this information for free without a database
by using the MSN Virtual Earth script generated by this URL:
http://local.live.com/WiFiIPService/locate.ashx
What this does is return a function, SetAutoLocateViewport, that you can use
with the MapControl.js VE Maps control. which can also be used to lookup the
city, state information.
SetAutoLocateViewport(28.5418, -81.3736, 10, false, 'Virtual Earth has
determined your location by using your computer's IP address.');
Note that the first two parameters represent the latitude and longitude of
the IPAddress represented by your REMOTE_HOST server variables.
Here's an article I did on this with more info (and a much smaller database,
in binary form as an embedded resource):
http://www.eggheadcafe.com/articles/20051109.asp
I am not familiar with how efficient their binary file lookup is, probably
the best way to find out is to ask the vendor. I suspect since they expect
high-volume usage that they've figured out how to optimize it.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Fabuloussites" wrote:

> I'm considering deploying an application that will us an IP address locait
on
> database provided by Ip2location.com...
> http://www.ip2location.net/ip2locat...-component.aspx
> their .net component reads data from a binary file. I'm guess i'm wonderi
ng
> which of the two options would be best.
> 1) read data from the binary files (~27 mb or so)
> 2) or query a sql DB with the same info.
> The database will have about 8 columns and ~ 1.8 millions rows.
> i'm developing for a high traffic webisite, and i would like to query this
> DB to get the City info from the DB when a visitor first visits the site
> (based on their ip address).
> Also, how do serialized binary files handle simultaneous file access? Wou
ld
> a high traffic webisite be able to use a serialized file efficiently if th
e
> file was read often?
> Thanks!
Thanks for the useful information. I was not aware of the localive service.
However, i've notice that i'm getting a consistent "Server currently busy,
Try again Later" message. Is there a commercial web service that will be
more reliable? Will this web service remain free?
thanks!
"Peter Bromberg [C# MVP]" wrote:
> Actually,
> you can get all this information for free without a database
> by using the MSN Virtual Earth script generated by this URL:
> http://local.live.com/WiFiIPService/locate.ashx
> What this does is return a function, SetAutoLocateViewport, that you can u
se
> with the MapControl.js VE Maps control. which can also be used to lookup t
he
> city, state information.
> SetAutoLocateViewport(28.5418, -81.3736, 10, false, 'Virtual Earth has
> determined your location by using your computer's IP address.');
> Note that the first two parameters represent the latitude and longitude of
> the IPAddress represented by your REMOTE_HOST server variables.
> Here's an article I did on this with more info (and a much smaller databas
e,
> in binary form as an embedded resource):
> http://www.eggheadcafe.com/articles/20051109.asp
> I am not familiar with how efficient their binary file lookup is, probably
> the best way to find out is to ask the vendor. I suspect since they expect
> high-volume usage that they've figured out how to optimize it.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Fabuloussites" wrote:
>
i found info on the live local service. Looks like it is still in beta
format.
http://download.microsoft.com/downl...iveLocalFAQ.doc
thanks for the info. i think i will try to get access to a sample database
and use your methods to make my own binary files. their component only work
s
with dot net 1.x and i want to use a 2.0 app.
thanks!
"Fabuloussites" wrote:
> Thanks for the useful information. I was not aware of the localive servic
e.
> However, i've notice that i'm getting a consistent "Server currently busy,
> Try again Later" message. Is there a commercial web service that will be
> more reliable? Will this web service remain free?
> thanks!
> "Peter Bromberg [C# MVP]" wrote:
>
If it's only 27mb, why not just read the whole thing and put it in memory?
"Fabuloussites" <Fabuloussites@.discussions.microsoft.com> wrote in message
news:D3FEF3C4-5341-40CD-BE58-A8B915B4DB6B@.microsoft.com...
> I'm considering deploying an application that will us an IP address
> locaiton
> database provided by Ip2location.com...
> http://www.ip2location.net/ip2locat...-component.aspx
> their .net component reads data from a binary file. I'm guess i'm
> wondering
> which of the two options would be best.
> 1) read data from the binary files (~27 mb or so)
> 2) or query a sql DB with the same info.
> The database will have about 8 columns and ~ 1.8 millions rows.
> i'm developing for a high traffic webisite, and i would like to query this
> DB to get the City info from the DB when a visitor first visits the site
> (based on their ip address).
> Also, how do serialized binary files handle simultaneous file access?
> Would
> a high traffic webisite be able to use a serialized file efficiently if
> the
> file was read often?
> Thanks!
As mentioned before, i'm really new to this type of situation. So, i was
just trying to get some input regaring the performance of using a binary
file, vs a SQL server.
"PJ" wrote:

> If it's only 27mb, why not just read the whole thing and put it in memory?
> "Fabuloussites" <Fabuloussites@.discussions.microsoft.com> wrote in message
> news:D3FEF3C4-5341-40CD-BE58-A8B915B4DB6B@.microsoft.com...
>
>
either way it's a wash if you just cache the information and code something
to update the cache every...what...day? how often does city state
information change?
"Fabuloussites" <Fabuloussites@.discussions.microsoft.com> wrote in message
news:83853729-F280-4CE6-A619-8E1EAA662751@.microsoft.com...
> As mentioned before, i'm really new to this type of situation. So, i was
> just trying to get some input regaring the performance of using a binary
> file, vs a SQL server.
> "PJ" wrote:
>
I see you point. my concern is that i'm going to query this data for every
visitor to the website to determine what content to show them. So, this inf
o
will be queried when a user first visits the site to obtain the city/state
info and store it in a cookie or something. So, i was not sure how accessin
g
1.8 million rows of data would impact the performace if the site had high
traffic.
"PJ" wrote:

> either way it's a wash if you just cache the information and code somethin
g
> to update the cache every...what...day? how often does city state
> information change?
>
> "Fabuloussites" <Fabuloussites@.discussions.microsoft.com> wrote in message
> news:83853729-F280-4CE6-A619-8E1EAA662751@.microsoft.com...
>
>
A properly setup database will perform better, I believe.
But testing is the only way to check for sure.
..
You need to properly index the table, esp with that many rows.
The addage of "if the column is in the where clause, then index it" may
not be sufficient here. You need to determine the exact query usage.
www.sqlservercentral.com would be a good resource for that kind of sql
server performance question.
Fabuloussites wrote:
> I'm considering deploying an application that will us an IP address locait
on
> database provided by Ip2location.com...
> http://www.ip2location.net/ip2locat...-component.aspx
> their .net component reads data from a binary file. I'm guess i'm wonderi
ng
> which of the two options would be best.
> 1) read data from the binary files (~27 mb or so)
> 2) or query a sql DB with the same info.
> The database will have about 8 columns and ~ 1.8 millions rows.
> i'm developing for a high traffic webisite, and i would like to query this
> DB to get the City info from the DB when a visitor first visits the site
> (based on their ip address).
> Also, how do serialized binary files handle simultaneous file access? Wou
ld
> a high traffic webisite be able to use a serialized file efficiently if th
e
> file was read often?
> Thanks!

Serializing an object from a DLL

I am using SQL to hold session state. My problem is that I have an object
that I want to store in Session State. I can not mark the class it comes from
as Serializable because it is from a DLL that I do not have the code for.
There must be an easy way to do this I just can't figure it out.

This is the code that Serializes the item that I want to place in a Session.

private string Serialize(SessionStateItemCollection items)
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);

if (items != null)
items.Serialize(writer);

writer.Close();

return Convert.ToBase64String(ms.ToArray());
}

I'd really appreciate anyone who could help.unless its sealed, make a new object that inherits from it, and enable
serialization.

the underlying object may not really support serialization (use of unmanged
code, active streams / connections, non-serializable objects). in this case
you can write a custom serializier read/write out the properties, and
perform required initialization.

-- bruce (sqlwork.com)

"Harry" wrote:

Quote:

Originally Posted by

I am using SQL to hold session state. My problem is that I have an object
that I want to store in Session State. I can not mark the class it comes from
as Serializable because it is from a DLL that I do not have the code for.
There must be an easy way to do this I just can't figure it out.
>
>
This is the code that Serializes the item that I want to place in a Session.
>
private string Serialize(SessionStateItemCollection items)
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);
>
if (items != null)
items.Serialize(writer);
>
writer.Close();
>
return Convert.ToBase64String(ms.ToArray());
}
>
I'd really appreciate anyone who could help.

Serializing an object from a DLL

I am using SQL to hold session state. My problem is that I have an object
that I want to store in Session State. I can not mark the class it comes fro
m
as Serializable because it is from a DLL that I do not have the code for.
There must be an easy way to do this I just can't figure it out.
This is the code that Serializes the item that I want to place in a Session.
private string Serialize(SessionStateItemCollection items)
{
MemoryStream ms = new MemoryStream();
BinaryWriter writer = new BinaryWriter(ms);
if (items != null)
items.Serialize(writer);
writer.Close();
return Convert.ToBase64String(ms.ToArray());
}
I'd really appreciate anyone who could help.unless its sealed, make a new object that inherits from it, and enable
serialization.
the underlying object may not really support serialization (use of unmanged
code, active streams / connections, non-serializable objects). in this case
you can write a custom serializier read/write out the properties, and
perform required initialization.
-- bruce (sqlwork.com)
"Harry" wrote:

> I am using SQL to hold session state. My problem is that I have an object
> that I want to store in Session State. I can not mark the class it comes f
rom
> as Serializable because it is from a DLL that I do not have the code for.
> There must be an easy way to do this I just can't figure it out.
>
> This is the code that Serializes the item that I want to place in a Sessio
n.
> private string Serialize(SessionStateItemCollection items)
> {
> MemoryStream ms = new MemoryStream();
> BinaryWriter writer = new BinaryWriter(ms);
> if (items != null)
> items.Serialize(writer);
> writer.Close();
> return Convert.ToBase64String(ms.ToArray());
> }
> I'd really appreciate anyone who could help.

Thursday, March 22, 2012

Serializng objects for SQL State management

Hello all,

I am trying to migrate my site from In-proc state management to out-of-proc
SQL state management.

I am having problems with the serialization of my classes.

I have added the [Serializable] attribute to the classes, which works, but
some of the classes' objects (XmlDocument is one example), are causing
errors:

"[SerializationException: The type System.Xml.XmlDocument in Assembly
System.Xml, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 is not marked as serializable.]"

Is there a quick way around this? Perhaps creating a derived class from
XmlDocument that is marked as serializable, or is there another attribute or
solution that I am missing?

Thanks for your help,

- gskIf a class isn't serializable, than any classes that derive from it wouldn't
be serializable.
What you could do, though is expose a property for your XmlDocument but have
the document itself strored as a string within the provate variable, so in
your get/set you instantiate an XmlDocument, load it with the string and
then return it to the user.

The problem, though, would be that the string would be passed by value, so
if a process just got the document and modified it, that procedd would have
to re-set the property for the private variable to get the changes.

Another option...

DataSets are serializable, so if your document id structured in a way that
loading it into a dataset wouldn be too strange, that might be a good way of
handling it

"GSK" <gsk@.NiOcSaP.nAeMt> wrote in message
news:uhZriNoOEHA.3300@.TK2MSFTNGP09.phx.gbl...
> Hello all,
> I am trying to migrate my site from In-proc state management to
out-of-proc
> SQL state management.
> I am having problems with the serialization of my classes.
> I have added the [Serializable] attribute to the classes, which works, but
> some of the classes' objects (XmlDocument is one example), are causing
> errors:
> "[SerializationException: The type System.Xml.XmlDocument in Assembly
> System.Xml, Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089 is not marked as serializable.]"
> Is there a quick way around this? Perhaps creating a derived class from
> XmlDocument that is marked as serializable, or is there another attribute
or
> solution that I am missing?
> Thanks for your help,
> - gsk

Serializng objects for SQL State management

Or another option is to just output the XML Document as a string
containing the XML.

That should Serialize fine.

Hth,

Phil Winstanley
Microsoft ASP.NET MVPThanks guys,

As I already had a method for returning the OuterXml of the XmlDocument,
saving that value in session, then subsequently re-creating my object using
the string as an input parameter has done the trick.

Thanks for the advice!

- gsk.

"Phil Winstanley [Microsoft MVP]" <phil@.winstanley.name> wrote in message
news:c85a58$obm@.odah37.prod.google.com...
> Or another option is to just output the XML Document as a string
> containing the XML.
> That should Serialize fine.
> Hth,
> Phil Winstanley
> Microsoft ASP.NET MVP

Serializng objects for SQL State management

Hello all,
I am trying to migrate my site from In-proc state management to out-of-proc
SQL state management.
I am having problems with the serialization of my classes.
I have added the [Serializable] attribute to the classes, which works, b
ut
some of the classes' objects (XmlDocument is one example), are causing
errors:
"[SerializationException: The type System.Xml.XmlDocument in Assembly
System.Xml, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 is not marked as serializable.]"
Is there a quick way around this? Perhaps creating a derived class from
XmlDocument that is marked as serializable, or is there another attribute or
solution that I am missing?
Thanks for your help,
- gskIf a class isn't serializable, than any classes that derive from it wouldn't
be serializable.
What you could do, though is expose a property for your XmlDocument but have
the document itself strored as a string within the provate variable, so in
your get/set you instantiate an XmlDocument, load it with the string and
then return it to the user.
The problem, though, would be that the string would be passed by value, so
if a process just got the document and modified it, that procedd would have
to re-set the property for the private variable to get the changes.
Another option...
DataSets are serializable, so if your document id structured in a way that
loading it into a dataset wouldn be too strange, that might be a good way of
handling it
"GSK" <gsk@.NiOcSaP.nAeMt> wrote in message
news:uhZriNoOEHA.3300@.TK2MSFTNGP09.phx.gbl...
> Hello all,
> I am trying to migrate my site from In-proc state management to
out-of-proc
> SQL state management.
> I am having problems with the serialization of my classes.
> I have added the [Serializable] attribute to the classes, which works,
but
> some of the classes' objects (XmlDocument is one example), are causing
> errors:
> "[SerializationException: The type System.Xml.XmlDocument in Assembly
> System.Xml, Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089 is not marked as serializable.]"
> Is there a quick way around this? Perhaps creating a derived class from
> XmlDocument that is marked as serializable, or is there another attribute
or
> solution that I am missing?
> Thanks for your help,
> - gsk
>
Or another option is to just output the XML Document as a string
containing the XML.
That should Serialize fine.
Hth,
Phil Winstanley
Microsoft ASP.NET MVP
Thanks guys,
As I already had a method for returning the OuterXml of the XmlDocument,
saving that value in session, then subsequently re-creating my object using
the string as an input parameter has done the trick.
Thanks for the advice!
- gsk.
"Phil Winstanley [Microsoft MVP]" <phil@.winstanley.name> wrote in messag
e
news:c85a58$obm@.odah37.prod.google.com...
> Or another option is to just output the XML Document as a string
> containing the XML.
> That should Serialize fine.
> Hth,
> Phil Winstanley
> Microsoft ASP.NET MVP
>

Serious problem with SQL database query (please help)

Hello, I have a serious problem dealing with database interrogation through SQL statements. To interrogate my database of employees by surname, I use the following code:


Dim mykeyword As String = txtKeyWord.Text
Dim MySQL as string = "Select * from employees WHERE surname = '" & mykeyword & "' Order by id_employee"

Dim myConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & server.mappath("employees.mdb") & ";")
Dim ds as DataSet=New DataSet()

Dim Cmd as New OleDbDataAdapter(MySQL,MyConn)
Cmd.Fill(ds,"employees")

myDataGrid.Datasource=ds.Tables("employees").DefaultView
myDataGrid.DataBind()
MyConn.Close()

Now, the problem arises when the user types one or more apostrophes (') in the TextBox for the keyword. The apostrophes interfere with the SQL string and the search simply fails.

I suppose I should check the content of the textbox before executing the query, to make sure there are no invalid characters, but I don't know how to look for a specific character in a string and replace it.

Besides, I think that it would be absurd to prevent the user from typing apostrophes because that character is so common that it would become a serious limitation.

I suppose I am not the first person who has encountered such a problem, so if you know the solution, please help me.

Thanks in advance.You can try:

Dim MySQL as string = "Select * from employees WHERE surname = '" & mykeyword.Replace("'","'+CHAR(39)+'") & "' Order by id_employee"
Also, this will help you to prevent SQL injections.
Usually replacing single apostrophe with pare, fixes the problem. Try

Dim MySQL as string = "Select * from employees WHERE surname = '" & mykeyword.Replace("'", "''") & "' Order by id_employee"


THANK YOU !!! Your help was great!

Server 2003 Web Edition Communicating with SQL Server on LAN

I am having problems getting my Web Server to communicate with the SQL server. My code works perfectly when running it from the SQL server (so it's seeing the database) but when I try to run it from the Web Server, it isn't seeing it. I am not a ASP programmer by any stretch and would appreciate any assistance in getting this to communicate. Thanks!

Ryan


is there an error?


There is not error. The drop down's that should be populated on the page, just don't show up. So the code populates these drop downs by utilizing data in the database. The fact they don't show up when running it from the web server seems like the database isn't being accessed. This page is a search page that queries people's information from the database. When I run the search it doesn't display anyone either. Firefox gives me this:

<%'CreateSelectList "LOCATION", "Location:","Choose a location", "LOCAT" 'CreateSelectList "EDUCATION", "Education:","Choose an education", "EDUCA" CreateSelectList "LANGUAGE", "Language:","Choose a language", "LANGE" 'CreateSelectList "ETHNIC", "Ethnic Origin:","Choose an ethnicity", "ETHNC"%>
 
IE just gives me this:
 "> 

Thats really not going to help sadly, You're going to have to dig into the code to test it out.

I know you can not install SQL on Web Edition, but as far as I know you can access it.
How was this configured before? What was changed/upgraded/etc... It's most likely just a config issue.


The wierd part about it is that it works perfectly on the SQL server itself. This exact code. All I did is move it to the Web Server, setup and ODBC connection, and then browse to the page again. That's it. So I don't know if you have any suggestions on the ODBC connection or if you can point me to a tutorial that would give me a step by step explanation on how to set this up. I do know that when I setup the ODBC connection, it says the test was "SUCCESSFUL" when connecting to the database. thanks for your prompt reply. I'm "under the gun" to get this going!

Ryan


I think we'll need to see some code for the web page itself and the code that accesses the database (if it is somewhere else).


go into the SQL configuration, make sure that "allow remote connections" is enabled.

Its not the webserver, its the db server thats blocking you


Below is what I use to connect to the database. I have the "Uncomment to display information about the server" portion uncommented and on the SQL server, when I browse to the search page, it displays exactly what I am connecting with. All the credentials are there. On the web server when I browse to the web page, it doesn't display the connection information and I just get the "junk" that I showed you in previous post.

<%' This file is to be included to set the path to the data for the connections' and other global variables.Dim strServer,strDB,strDBO,oSQL,strAuthMode,strUser,strPass,strImagePathstrServer="RIECSS01" ' This is the Server on which the data resides.strDB="Echo_live" ' This is the name of the database being accessed.strDBO ="dbo" 'This is the database owner to connect as.strAuthMode=""' Enter "SQL" to use SQL Server Authentication instead of Integrated (Windows) Auth.strUser=""' Not used unless strAuth="SQL"strPass=""' Not used unless strAuth="SQL"strImagePath="http://RIECSS01/ECHO/ECHO_image/depot_final/" 'Set this to your image path for provider photos in HTTP format. Ex: "http://server/images/"if strAuthMode="SQL" thenstrServer="^Server~"+strServer+"^LOGIN~"+strUser+"^PASSWORD~"+strPass+"^SQLA~Y"end if' --- Set Canadian Flag ---' Set the flag for whether the client is Canadian' If this is flagged as "YES" the following happens'(1) The word "ZIP CODE" becomes "Postal Code" '(2) The distance functions calculate in terms of Kilometers'(3) The word "Miles" becomes "Kilometers" wherever distance is displayedsession.Value("canada")="NO" 'Uncomment to display information about the serverResponse.Write "br>the server is:" &strServerResponse.Write "<br>the Database is:" &strDBResponse.Write "<br>the DBO is:" &strDBO' ----Create the oSQL SQL Select Object ----set oSQL = CreateObject("QEDATA.SQLSelect") 'This is the database connection object.' --- This function changes the spaces to %20function RidSpaces(vlu)RidSpaces = replace(vlu," ","%20")end function' ---- This function changes \ to /function FixBackSlash(vlu)FixTick = Replace(vlu,"\","/")end function' ------- This function removes the tick "'" mark' look into possibly using htmlEncode() for thisfunction FixTick(vlu)FixTick = Replace(vlu,"'","''")end function' ------- Rids the path and returns only the filenamefunction RidPath(vlu)RidPath = trim(right(vlu, len(vlu)- InstrRev(vlu,"\"))) end function 'Write to hitsdim strPage, strID, strHitSQLstrPage = mid(Request.ServerVariables("script_name"), instrrev(Request.ServerVariables("script_name"), "/") + 1)strID = Request.QueryString("id")strHitSQL = "insert into msl_hits(dte, time, page, dr_id) values('"&date()&"', convert(varchar(8), getdate(), 8), '" & strPage & "', '" & strID & "')"oSQL.Insert_Record strServer, strDB, strHitSQL' end code block%>

Curt,

I am running SQL Server 2000. When I go into enterprise manager and go to properties, I go to security. I have SQL Server and Windows selected as the authentication type. Under connections I have "Allow other SQL Servers to connect remotely to this SQL server using RPC" selected as well. Where else would I check? Thanks.

Ryan


I was under the impression it was SQL 2005...

does anything connect to this SQL server other then its own box? Just trying to see if thre is anytihg inbetween that may cause issues (firewall, router, etc).


No. That is the only database on there. When I do a trace route from the web server to the SQL server, there is nothing between them.


Hmm... do you have IIS on your PC?

Try loading the site on your machine once, see if it works from there. Just trying to see if its a config on the web server or something else...


IIS is on the web server, but the site isn't setup in IIS. I am just browsing to the .asp file through windows explorer. Does it actually need to be setup as a "website" in IIS first?

Also, I can connect to the website by browsing it to the SQL server directly from my local computer. So the site will run on my machine just fine if I access it on the SQL server from my machine. It won't run if I try to access the same code on the Web Server.


AGH....yes...

Asp.Net must be viewed in the context of a web server served site/application. They are parsed by the web server engine and rendered...


OK. So, I need to go into IIS and setup a website. Is there anything else I need to do? Is there a good tutorial you could point me to? (I have used apache my whole life so you will have to forgive me for these basic questions!) Thanks again for all your help.