Solved

remote db db connection

Posted on 2008-10-28
6
216 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
  • 4
6 Comments
 
LVL 2

Assisted Solution

by:smokingspaceman
smokingspaceman earned 50 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 450 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now