borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (What is portable executable (PE) file?)Next Topic (please help) New Topic New Poll Post Reply
AndreaVB Forum : ASP.Net : error
Poster Message
Lancerio84
Level: Guest


icon error

I have the following codes for a web service to call information from access database in a local server:

Imports System.Web.Services
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb


<System.Web.Services.WebService(Namespace:="http://tempuri.org/Webtry1/Service1")> _
Public Class Service1
    Inherits System.Web.Services.WebService

#Region " Web Services Designer Generated Code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Web Services Designer.
        InitializeComponent()

        'Add your own initialization code after the InitializeComponent() call

    End Sub

    'Required by the Web Services Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Web Services Designer
    'It can be modified using the Web Services Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container
    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        'CODEGEN: This procedure is required by the Web Services Designer
        'Do not modify it using the code editor.
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

#End Region
    Private Const DSN As String = _
    "server=andreavb.ipowermysql.com;database=RepairWorks;user id=Admin;password=;"

    <WebMethod()> Public Function GetCategories() As String()
        Dim oCon As New SqlConnection(DSN)
        Dim sSql As String
        sSql = "SELECT ProjectNo FROM RepairWorkStatus"
        Dim oCmd As New SqlDataAdapter(sSql, oCon)
        Dim oDS As New DataSet
        Dim sReturn() As String
        Dim I As Integer

        oCmd.Fill(oDS, "RepairWorkStatus")
        ReDim sReturn(oDS.Tables(0).Rows.Count)
        For I = 0 To oDS.Tables(0).Rows.Count - 1
            sReturn(I) = CStr(oDS.Tables(0).Rows(I).Item(0))
        Next
        Return sReturn
    End Function

The problem is when i run the application and click on the invoke button:
the following error accured:
System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

I tried many ways but it still has the same error..can anyone help??

14-09-2004 at 09:13 AM
| Quote Reply
zimcoder
Level: VB Lord


Registered: 27-10-2003
Posts: 225
icon Re: error

quote:
Lancerio84 wrote:    Private Const DSN As String = _
    "server=andreavb.ipowermysql.com;database=RepairWorks;user id=Admin;password=;"



Your problem is emanating from here

Are you running this application on your local machine? if you are.
Make sure that
1) The database called RepairWorks is present on the machine that has your web application.
2) The user Admin is registered as a user of the database and make sure that u have used the correct password in the connection string.

You can also solve this by adding a user to your database and making sure the user has sufficient permissions on the database, you can then change the connection string appropriately.

While you are @ it you may want to store your connection string in the web.config file, it will make it easy to configure without recompiling your project

____________________________
BrainBench ADO.NET and ASP.NET Certified Developer

14-09-2004 at 12:53 PM
View Profile Send Email to User Show All Posts | Quote Reply
Lancerio84
Level: Guest

icon Re: error

Ya it is running locally and the database is in my desktop. What do you mean by having to move the database to where my web service is?

15-09-2004 at 01:03 AM
| Quote Reply
AndreaVB Forum : ASP.Net : error
Previous Topic (What is portable executable (PE) file?)Next Topic (please help) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder