<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
|
zimcoder Level: VB Lord Registered: 27-10-2003 Posts: 225
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
|
Lancerio84 Level: Guest
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?