?
Solved

remote db db connection

Posted on 2008-10-28
6
Medium Priority
?
224 Views
Last Modified: 2012-05-05
hello there,

can you please give me a simple asp.net code. so i can test my website db connection.

cheers
ZOlf
0
Comment
Question by:zolf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 2

Assisted Solution

by:smokingspaceman
smokingspaceman earned 200 total points
ID: 22820089
Assuming you're using SQL server;
    Public Function select(ByVal sqlQuery As String)
        Dim dataset As New DataSet
        Try
            Dim Connection As SqlConnection
            Connection = New SqlConnection(Data Source=computer\SQLEXPRESS;Initial Catalog=table;User ID=x;Password=y)
            Dim adapter As New SqlDataAdapter
            adapter.SelectCommand = New SqlCommand(sqlQuery, Connection)
            adapter.Fill(dataset, "temp")
        Catch ex As Exception
        End Try
        Return dataset
    End Function
0
 

Author Comment

by:zolf
ID: 22820117
do i just copy and paste the cope into a notepad and save it as test.aspx.and in then call it from my website
0
 

Author Comment

by:zolf
ID: 22820120

i just want to test connection.i dont have any table in my db now.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:zolf
ID: 22820155

i tried something like this.but i get this ierror

Microsoft OLE DB Provider for SQL Server error '80004005'

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

/conn.asp, line 4

<%
Dim conn, rs
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;server=<202.***.***.***>;Database=<abc>;uid=<eawj>;pwd=<****>"
set rs = Server.CreateObject("ADODB.RecordSet")
%>
0
 

Author Comment

by:zolf
ID: 22820162

the db is not on my computer.i am trying to connect to my hosting's db
0
 
LVL 16

Accepted Solution

by:
Gyanendra Singh earned 1800 total points
ID: 22820264
error suggest server address is not correct or username through you are trying to connect is not correct .. please check
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question