Showing posts with label asp. Show all posts
Showing posts with label asp. Show all posts

Wednesday, March 28, 2012

how to make select query to access view in other server

Dear All,

i am making small web application using asp.net, C# ,sql2000.

i want a about regarding how to access view or table from other server to local server. i have base database where there is a view which need to access in my database of local server.
that is how to make select query to access view in other server

Please help


thanks

You have to add you second server to linked servers (server objects-> linked servers-> right click new linked server) and next in your query use server name in table name like:

select * from [server].[database].dbo.[tablename]

or use open query

Select * from OPENQUERY([servername],'SELECT * from [database].dbo.[tablename]')

second is faster but use it only if your query will hit only data on second server.

Thanks

sql

how to make select query to access view in other server

Dear All,

i am making small web application using asp.net, C# ,sql2000.

i want a about regarding how to access view or table from other server to local server. i have base database where there is a view which need to access in my database of local server.
that is how to make select query to access view in other server
Please help


thanks

there are many ways to access other server.database.table

(a) Configure LinkedServer

b)OPENDATASOURCE

(c) OpenQuery

read about this in BOL

Madhu

Wednesday, March 21, 2012

How to make a "SQL Server" connection with ASP.NET

Hi.

Working with ASP this connection works:


stringMyConn = "dsn=foo.com.bar;uid=john;pwd=xxxx;"
set myConn = Server.CreateObject("ADODB.Connection")
myConn.open stringMyConn

But it doesn't with ASP.NET

Dim myConn As SqlConnection = New SqlConnection("dsn=foo.com.bar;uid=john;pwd=xxxx;")
myConn.Open

What am I doing wrong? Thank you very much.

Since you are connecting to SQL Server, I don't recommend that you use a DSN connection. You can connect to SQL server as follows:

Dim myConn As New SqlConnection("server=;database=;user id=;password=;")
Dim myCmd As New SqlCommand("SELECT * FROM SOMETHING", myConn)

myConn.Open()

' ... Some code here to do something with the SqlCommand object

myConn.Close()

For future reference, a good source for connection strings isConnectionStrings.com.

How to maintain transaction between two databases?

Hi All,

Pandon me for asking such question, I am still a beginner to ASP.NET.

I have a project that require me to do single operation that is suppose to update two databases, wonder how do I maintain transaction between these two databases? Please advise, thank you!

Are these two different databases ?? Or two different tables in a database ?

If there are two tables inside one database, then you can keep a transaction object of ADO.NET

regards

|||

They are two different database. One database in each server sitting in a WAN. =(

|||

Hi,

To use transactions across database or servers, I suggest you use the TransactionScope class.

Here is an article for your reference.

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

HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!

sql

Friday, March 9, 2012

How to link ASP with SQL Express 2005?

Hi, I am trying to link my ASP project with my SQL server but ASp 2005 is pretty different from the earlier version. I don't even see any Data Adapter. I set all my rights for my SQL server so I believe that all I have left to do now is to link them together. I hope someone can help me.It's not that different at all from previous versions. You can check outthese tuts to guide you through it.