473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Problem with SQLParameter data type (because 'System.Data.SqlClient.SqlParameter' is not derived from 'StoreBO.StoreBackOffice.SqlParameter'. )

I have a webservice that has the below procedure. Basically a procedure to
called a stored procedure and return the results. When I try to call the
webservice from my program I get the error. Both my calling code and the
webservice code are below. Thanks for your help.
D:\Projects .NET\StoreBO\frmVoids.vb(182): Value of type '1-dimensional
array of System.Data.SqlClient.SqlParameter' cannot be converted to
'1-dimensional array of StoreBO.StoreBackOffice.SqlParameter' because
'System.Data.SqlClient.SqlParameter' is not derived from
'StoreBO.StoreBackOffice.SqlParameter'.
--------------------------- CODE CALLING WEBSERVICE HERE

Private Sub GetData(Optional ByVal MyFilter As Integer = 0)

Me.Cursor = Cursors.WaitCursor
Dim MyParams() As SqlParameter
ReDim Preserve MyParams(5)

MyParams(0) = New SqlParameter("@StartDate",

Me.dteStart.Value.ToShortDateString)

MyParams(1) = New SqlParameter("@EndDate",

Me.dteStart.Value.ToShortDateString)

MyParams(2) = New SqlParameter("@Store", MyFilter)

MyParams(3) = New SqlParameter("@UnVerifiedOnly", 0)

MyParams(4) = New SqlParameter("@PostVoidsOnly", 0)

MyParams(5) = New SqlParameter("@PostVoidTimeDifference", 0)

Dim RsTemp As DataSet

RsTemp = New DataSet

Me.grdVoids.DataSource = Nothing
Dim rsData As New DataSet

Dim MySvc As New StoreBackOffice.StoreBackOffice

Dim ErrorMsg As String = "Error getting Post Void Information"

Try

If MySvc.GetDataFromStoredProcedure(MerchConn,

"vm_VoidsAudit", MyParams, MerchConn, ErrorMsg, RsTemp, "Voids", 120) = True
Then

rsData.Clear()

rsData.Merge(RsTemp)

Me.grdVoids.DataSource = rsData.Tables("Voids")

Else

MessageBox.Show(ErrorMsg, "Error getting Void Data", MessageBoxButtons.OK,
MessageBoxIcon.Error)

End If

Catch ex As System.Exception

Dim sMsg As String = "There has been an error Post Voids Information : " &
ex.ToString

MessageBox.Show(sMsg, "Error loading data", MessageBoxButtons.OK,
MessageBoxIcon.Error)

Finally
End Try
RsTemp.Dispose()

Me.Cursor = Cursors.Default
End Sub


--------------------------WEB SERVICE METHOD BELOW
<WebMethod()> _

Public Function GetDataFromStoredProcedure(ByVal dbConn As String, ByVal
MySproc As String, ByVal MyParams() As SqlParameter, ByVal MyConn As String,
ByRef ErrorDesc As String, ByRef ReturnDS As DataSet, ByVal DataName As
String, ByVal MyTimeout As Integer) As Boolean

Dim oConn As New SqlConnection(dbConn)

Dim bRetVal As Boolean

Try

Dim MyCmd As New SqlCommand(MySproc, oConn)

MyCmd.CommandTimeout = MyTimeout

MyCmd.CommandType = CommandType.StoredProcedure

Dim p As SqlParameter

If IsNothing(MyParams) = False Then

For Each p In MyParams

p = MyCmd.Parameters.Add(p)

p.Direction = ParameterDirection.Input

Next

End If

Dim oAdapt As New SqlDataAdapter(MyCmd)

MyCmd.Prepare()

oConn.Open()

oAdapt.Fill(ReturnDS, DataName)

'oConn.Dispose()

MyCmd.Dispose()

oConn.Dispose()

bRetVal = True

Catch ex As System.Exception

Dim sMsg As String = ErrorDesc & "(" & MySproc & ") : " & ex.Message

ErrorDesc = sMsg

bRetVal = False

Finally
End Try

Return bRetVal

End Function
Nov 21 '05 #1
3 2734
Stacey,

To overcome these problems the best thing you can do is set in the top of
your programs

Option Strict on
Than this kind of problems will be showed (mostly) in your code.

Cor
Nov 21 '05 #2
I do have option Strict On. The problem would more than likely go away if I
did not have this on. The problem is for some reason the SQLParameter type
is getting changed when I reference a webservice that takes that as a
parameter. Within the webservice it is fine.. it is just a problem in the
referencing program.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Stacey,

To overcome these problems the best thing you can do is set in the top of
your programs

Option Strict on
Than this kind of problems will be showed (mostly) in your code.

Cor

Nov 21 '05 #3
Hi

From the error, it seems to be a casting error.
This is because the WebService wanted a himself defined SqlParameter class
as below.
This is included in the Reference.vb file in the web service generated
client.

Because WebService can be consumed by many client, e.g. java, so the .NET
defined SqlParameter class is not specifed in java, the Webservice then
define a described SqlParameter.
<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://tempuri.org/
TestWS/Service1")> _
Public Class SqlParameter
Inherits MarshalByRefObject

'<remarks/>
Public DbType As DbType

'<remarks/>
<System.ComponentModel.DefaultValueAttribute(SqlDb Type.NVarChar)> _
Public SqlDbType As SqlDbType = SqlDbType.NVarChar

'<remarks/>

<System.ComponentModel.DefaultValueAttribute(Param eterDirection.Input)> _
Public Direction As ParameterDirection = ParameterDirection.Input

'<remarks/>
<System.ComponentModel.DefaultValueAttribute(false )> _
Public IsNullable As Boolean = false

'<remarks/>
<System.ComponentModel.DefaultValueAttribute(0)> _
Public Offset As Integer = 0

'<remarks/>
<System.ComponentModel.DefaultValueAttribute("") > _
Public ParameterName As String = ""

'<remarks/>
<System.ComponentModel.DefaultValueAttribute(GetTy pe(System.Byte),
"0")> _
Public Precision As Byte = CType(0,Byte)

'<remarks/>
<System.ComponentModel.DefaultValueAttribute(GetTy pe(System.Byte),
"0")> _
Public Scale As Byte = CType(0,Byte)

'<remarks/>
<System.ComponentModel.DefaultValueAttribute(0)> _
Public Size As Integer = 0

'<remarks/>
<System.ComponentModel.DefaultValueAttribute("") > _
Public SourceColumn As String = ""

'<remarks/>

<System.ComponentModel.DefaultValueAttribute(DataR owVersion.Current)> _
Public SourceVersion As DataRowVersion = DataRowVersion.Current

'<remarks/>
Public Value As Object
End Class

I think you may try to use the full qualified name as below to use the
Webservice SqlParameter in the winform client.
localhost.SqlParameter 'Webservice name is localhost.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Auto | last post by:
I starting to use Visual Studio .NET 2003 creating C# Windows application with SQL Server and I get problem with method Fill() for which when running ends with System Error even with the most...
5
by: Jason Huang | last post by:
Hi, The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is working for update, but SqlParameter myPM =new SqlParameter ("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is...
3
by: I am Sam | last post by:
Please help. I'm dying here and pulling out the last few remaining elements of my hair over this. I have built a form that will identify and authenticate users. I keep getting the following...
4
by: Bass Pro | last post by:
Hi, I am creating textbox, radiobuttonlist and checkboxlist dynamically depending on data from a table. It is a questionnaire. I add the control on a Panel control during the 1st load_page event....
5
by: hfk0 | last post by:
Hi, I'm new to ASP.net, SQL Server and visual studio.net, and I'm having problem inserting and storing data from a web form to a SQL database. I created a simple ASP.NET web form, a simple SQL...
1
by: KhoaNguyen | last post by:
i have two classes..one is a base and the other is inherited from the base class Below is my code -------ConnectionProvider class--------------------- using System; using...
0
by: stuart_dent | last post by:
I have a SQL Server table with in Indetity column (value auto generated). I have tried to write my own updatecommand code. I can't get it to work. An error says that says Sku and rid are...
3
by: kpeeroo | last post by:
Private Function AddCompanyOvertime() As Integer Dim companyID As Integer = GetCompanyID() Console.WriteLine(companyID) Dim paramCompanyID As New SqlParameter("@CompanyID",...
2
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.