Solved

remote db db connection

Posted on 2008-10-28
6
215 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

12 Experts available now in Live!

Get 1:1 Help Now