Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

remote db db connection

hello there,

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

cheers
ZOlf
0
zolf
Asked:
zolf
  • 4
2 Solutions
 
smokingspacemanCommented:
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
 
zolfAuthor Commented:
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
 
zolfAuthor Commented:

i just want to test connection.i dont have any table in my db now.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
zolfAuthor Commented:

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
 
zolfAuthor Commented:

the db is not on my computer.i am trying to connect to my hosting's db
0
 
Gyanendra SinghArchitectCommented:
error suggest server address is not correct or username through you are trying to connect is not correct .. please check
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now