DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 18 Jul 2007 19:32:14 +0100,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    DesCF
          2    Miha Markic miha at rthand com


DataAdapter with Parameter problem   
When I run the following code everything works fine (which proves the  stored procedure and the parameter:

       Dim cmdSQL As New SqlCommand
       cmdSQL.CommandType = CommandType.StoredProcedure
       cmdSQL.CommandText = "bdl_CustomerOrders_SELECT"
       cmdSQL.Connection = mcnnSQL
       Dim prm As New SqlParameter()
       prm.ParameterName = "@CustomerID"
       prm.Value = Me.cboCustomerSELECT.SelectedValue
       prm.Direction = ParameterDirection.Input
       cmdSQL.Parameters.Add(prm)
       mcnnSQL.Open()
       Dim dr As SqlDataReader
       dr = cmdSQL.ExecuteReader()
       While dr.Read
         Debug.WriteLine(dr.Item(0).ToString)
       End While
       dr.Close()


However, when I run the following code I get the error message:
Incorrect syntax near 'bdl_CustomerOrders_SELECT' at the last line:  sda.Fill(ds, "CustomerOrders")
Thoughts anyone ?


       Dim sda As New SqlDataAdapter("bdl_CustomerOrders_SELECT", mcnnSQL)
       Dim prm As SqlParameter =  sda.SelectCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5,  "CustomerID")
       prm.Direction = ParameterDirection.Input
       prm.SqlValue = Me.cboCustomerSELECT.SelectedValue
       sda.TableMappings.Add("Table1", "CustomerOrders")
       Dim ds As New DataSet()
       sda.Fill(ds, "CustomerOrders")




Des

-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Date:Wed, 18 Jul 2007 19:32:14 +0100   Author:  

Re: DataAdapter with Parameter problem   
Most probably you are missing this line:
sda.SelectCommand.CommandType = CommandType.StoredProcedure

-- 
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"DesCF"  wrote in message news:op.tvoa30jiupgxg0@descstar...

When I run the following code everything works fine (which proves the  
stored procedure and the parameter:

       Dim cmdSQL As New SqlCommand
       cmdSQL.CommandType = CommandType.StoredProcedure
       cmdSQL.CommandText = "bdl_CustomerOrders_SELECT"
       cmdSQL.Connection = mcnnSQL
       Dim prm As New SqlParameter()
       prm.ParameterName = "@CustomerID"
       prm.Value = Me.cboCustomerSELECT.SelectedValue
       prm.Direction = ParameterDirection.Input
       cmdSQL.Parameters.Add(prm)
       mcnnSQL.Open()
       Dim dr As SqlDataReader
       dr = cmdSQL.ExecuteReader()
       While dr.Read
         Debug.WriteLine(dr.Item(0).ToString)
       End While
       dr.Close()


However, when I run the following code I get the error message:
Incorrect syntax near 'bdl_CustomerOrders_SELECT' at the last line:  
sda.Fill(ds, "CustomerOrders")
Thoughts anyone ?


       Dim sda As New SqlDataAdapter("bdl_CustomerOrders_SELECT", mcnnSQL)
       Dim prm As SqlParameter =  
sda.SelectCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5,  
"CustomerID")
       prm.Direction = ParameterDirection.Input
       prm.SqlValue = Me.cboCustomerSELECT.SelectedValue
       sda.TableMappings.Add("Table1", "CustomerOrders")
       Dim ds As New DataSet()
       sda.Fill(ds, "CustomerOrders")




Des

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Date:Mon, 23 Jul 2007 15:05:30 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us