Home All Groups Group Topic Archive Search About

SQL Connection Query

Author
30 Sep 2006 6:36 AM
Poornima
Hi
I have a windows application in VB.net which creates a dataset and
updates the dataAdapter by connecting to the SQL Server 2005 and sends
the dataset as a parameter to my webService.My code is

Dim strCon As String
            Dim sValue As String
            Dim strQuery As String
            Dim dsEventTransac As New DataSet
            Dim daEventTransac As New SqlClient.SqlDataAdapter
            Dim rowCount As New Integer
            Dim oWebService As New WebReference.TkmService
            'Dim nwRow As DataRow
            'Dim delCmd As SqlClient.SqlCommand


            strQuery = "SELECT * FROM EventTransaction"

            strCon = "Data Source=localhost;integrated
security=SSPI;initial catalog=KmsDb;User ID=sa;password="
            objCon = New SqlClient.SqlConnection(strCon)
            If objCon.State = ConnectionState.Closed Then
                objCon.Open()
            End If
            daEventTransac = New SqlClient.SqlDataAdapter(strQuery,
objCon)
            Dim cmdBuilder As New
SqlClient.SqlCommandBuilder(daEventTransac)
            daEventTransac.Fill(dsEventTransac)

            'update the DataAdapter
            daEventTransac.Update(dsEventTransac)
            oWebService.Url =
"http://192.168.0.10/TkmService1/TkmService.asmx"
            sValue = oWebService.AcceptDataset(dsEventTransac)

            'MsgBox(sValue)
            'oWebService.AcceptDataset(dsEventTransac)
            'dgEventTransac.DataSource = Nothing

            ''display the table in a grid
            'dgEventTransac.DataSource = dsEventTransac.Tables(0)

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    'Private Sub DataGrid1_Navigate(ByVal sender As System.Object,
ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles
dgEventTransac.Navigate

    'End Sub
End Class

When running the above code in Visual Studio iam getting an error like

"System.WebServices.Protocols.SoapException:Server was unable to
process request---->
System.Data.SqlClient.SqlException:Loginfailed for user
"DESIGN-EMB/ASPNET.

where DESIGN-EMB is the name of my machine.

My webservice code is

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient
<WebService(Namespace:="http://192.168.0.10/TkmService1")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class TkmService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function AcceptDataset(ByVal mDsEventTransac As DataSet) As
String
        Dim objCon As New SqlConnection
        Dim strCon As String
        Dim strQuery As String
        Dim wDsEventTransac As New DataSet
        Dim daEventTransac As New SqlClient.SqlDataAdapter


        strQuery = "SELECT * FROM EventTransaction"

        strCon = "Data Source=localhost;integrated
security=SSPI;initial catalog=KmsDb;"
        objCon = New SqlClient.SqlConnection(strCon)
        If objCon.State = ConnectionState.Closed Then
            objCon.Open()
        End If
        daEventTransac = New SqlClient.SqlDataAdapter(strQuery, objCon)
        Dim cmdBuilder As New
SqlClient.SqlCommandBuilder(daEventTransac)
        daEventTransac.Fill(wDsEventTransac)

        'update the DataAdapter
        daEventTransac.Update(wDsEventTransac)

        'merge .sdf records with the .mdf records
        wDsEventTransac.Merge(mDsEventTransac)

        wDsEventTransac.AcceptChanges()
        wDsEventTransac = Nothing
        Return "Hello World"
    End Function

End Class

Can you tell me where iam wrong.

Thanks In Advance

Poornima

Author
30 Sep 2006 11:07 PM
Siva M
The ASP.NET worker process account (DESIGN-EMB/ASPNET) does not have access
to the database you are trying to access. Either explicitly specify the SQL
Server user name (which has sufficient rights to the DB) and password in the
connection string or give ASPNET user account permissions to your DB.


"Poornima" <poornima.venkatara***@gmail.com> wrote in message
news:1159598161.792902.16490@k70g2000cwa.googlegroups.com...
Hi
I have a windows application in VB.net which creates a dataset and
updates the dataAdapter by connecting to the SQL Server 2005 and sends
the dataset as a parameter to my webService.My code is

Dim strCon As String
            Dim sValue As String
            Dim strQuery As String
            Dim dsEventTransac As New DataSet
            Dim daEventTransac As New SqlClient.SqlDataAdapter
            Dim rowCount As New Integer
            Dim oWebService As New WebReference.TkmService
            'Dim nwRow As DataRow
            'Dim delCmd As SqlClient.SqlCommand


            strQuery = "SELECT * FROM EventTransaction"

            strCon = "Data Source=localhost;integrated
security=SSPI;initial catalog=KmsDb;User ID=sa;password="
            objCon = New SqlClient.SqlConnection(strCon)
            If objCon.State = ConnectionState.Closed Then
                objCon.Open()
            End If
            daEventTransac = New SqlClient.SqlDataAdapter(strQuery,
objCon)
            Dim cmdBuilder As New
SqlClient.SqlCommandBuilder(daEventTransac)
            daEventTransac.Fill(dsEventTransac)

            'update the DataAdapter
            daEventTransac.Update(dsEventTransac)
            oWebService.Url =
"http://192.168.0.10/TkmService1/TkmService.asmx"
            sValue = oWebService.AcceptDataset(dsEventTransac)

            'MsgBox(sValue)
            'oWebService.AcceptDataset(dsEventTransac)
            'dgEventTransac.DataSource = Nothing

            ''display the table in a grid
            'dgEventTransac.DataSource = dsEventTransac.Tables(0)

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    'Private Sub DataGrid1_Navigate(ByVal sender As System.Object,
ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles
dgEventTransac.Navigate

    'End Sub
End Class

When running the above code in Visual Studio iam getting an error like

"System.WebServices.Protocols.SoapException:Server was unable to
process request---->
System.Data.SqlClient.SqlException:Loginfailed for user
"DESIGN-EMB/ASPNET.

where DESIGN-EMB is the name of my machine.

My webservice code is

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient
<WebService(Namespace:="http://192.168.0.10/TkmService1")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class TkmService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function AcceptDataset(ByVal mDsEventTransac As DataSet) As
String
        Dim objCon As New SqlConnection
        Dim strCon As String
        Dim strQuery As String
        Dim wDsEventTransac As New DataSet
        Dim daEventTransac As New SqlClient.SqlDataAdapter


        strQuery = "SELECT * FROM EventTransaction"

        strCon = "Data Source=localhost;integrated
security=SSPI;initial catalog=KmsDb;"
        objCon = New SqlClient.SqlConnection(strCon)
        If objCon.State = ConnectionState.Closed Then
            objCon.Open()
        End If
        daEventTransac = New SqlClient.SqlDataAdapter(strQuery, objCon)
        Dim cmdBuilder As New
SqlClient.SqlCommandBuilder(daEventTransac)
        daEventTransac.Fill(wDsEventTransac)

        'update the DataAdapter
        daEventTransac.Update(wDsEventTransac)

        'merge .sdf records with the .mdf records
        wDsEventTransac.Merge(mDsEventTransac)

        wDsEventTransac.AcceptChanges()
        wDsEventTransac = Nothing
        Return "Hello World"
    End Function

End Class

Can you tell me where iam wrong.

Thanks In Advance

Poornima

AddThis Social Bookmark Button