Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links



Procedure datagrid stock - VB.Net

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 27-02-2009
Member
 
Join Date: Jan 2009
Posts: 150
Procedure datagrid stock - VB.Net

Hi all,

Here I want to put information in a Datagrid view from a stored procedure (which I call at a click of a button)
My DGV must fill.

Reader but when I execute my procedure it gets stuck, and I like error "Incorrect syntax near 'dbo'."

Code:
'Declare the connection 
          Sunday Connect As New System. Data. SqlClient. SqlConnection ( "Persist Security Info = False; Integrated Security = False; ccnetdev = uid, password = pw; Initial Catalog = UniversalActionLog; mydatabase = server") 
          'Open the Connection 
          Sunday myrow As DataRow 

          Connect. Open () 

          'SQL query, procedure call 
          Sunday myCommand As New SqlCommand ( "dbo.PS_LOG_Viewer", Connect) 
          Sunday myReader As SqlDataReader 

          Sunday myparam As SqlParameter 
          myparam = New SqlParameter ( "@ area", ComboBox_Area. SelectedItem) 
          myCommand. Parameters. Add (myparam) 

          Sunday myparam1 As SqlParameter 
          myparam1 = New SqlParameter ( "@ ACTION", ComboBox_Action. SelectedItem) 
          myCommand. Parameters. Add (myparam1) 

          Sunday myparam2 As SqlParameter 
          myparam2 = New SqlParameter ( "@ subactifs" ComboBox_SubAction. SelectedItem) 
          myCommand. Parameters. Add (myparam2) 


        
          myReader = myCommand. ExecuteReader () '<= This is where the error starts 
          Do While myReader. Read () 

              Myrow = GLOG. NewRow 
              GLOG. Rows. Add (myrow) 
       

          Loop 
          myReader. Close () 
          Connect. Close () 
  End Sub
Maybe you could enlighten me on my settings I do not know if it really like that make it work

Best regards
Reply With Quote
  #2  
Old 27-02-2009
Shell's Avatar
Member
 
Join Date: Mar 2008
Posts: 233
Re: Procedure datagrid stock - VB.Net

itself before you put exec dbo.maprocstock either you set CommandType to "StoredProcedure" on SqlCommand for the parameters is best typer, it is possible to set the value on the same line using the following syntax

Code:
 parameters. Add ( "@ p", nvarchar). value = the value
Reply With Quote
  #3  
Old 27-02-2009
Member
 
Join Date: Jan 2009
Posts: 150
Re: Procedure datagrid stock - VB.Net

Thank you, Shell

What you gave me is perfect

Code:
 Sunday myCommand As New SqlCommand ( "dbo.PS_LOG_Viewer", Connect) 
          myCommand. CommandType = CommandType. StoredProcedure
Parameter and also

Code:
 myCommand. Parameters. Add ( "@ area", SqlDbType. NVarChar). Value = ComboBox_Area. SelectedItem
This works even if my other procstoc that works perfectly I have called this way

Code:
 Sunday myCommand As New SqlCommand ( "dbo.PS_ACTION", Connect) 
          Sunday myReader As SqlDataReader
Strange that the other did perfect
Thank you again
Reply With Quote
  #4  
Old 27-02-2009
Shell's Avatar
Member
 
Join Date: Mar 2008
Posts: 233
Re: Procedure datagrid stock - VB.Net

I said rather strange that there have to spend ...
Reply With Quote
  #5  
Old 27-02-2009
Member
 
Join Date: Jan 2009
Posts: 150
Re: Procedure datagrid stock - VB.Net

Maybe because they are very small procedures that only return data from a column with a simple Select and From in a combobox
Reply With Quote
  #6  
Old 27-02-2009
Shell's Avatar
Member
 
Join Date: Mar 2008
Posts: 233
Re: Procedure datagrid stock - VB.Net

this is not an excuse, sql server request something he can understand just a name stored procedure, it does not exec proc stock includes select from it also CommandType to save the stored procedure allows the addition of implicit exec SqlCommand does not analyze the stored procedure.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Procedure datagrid stock - VB.Net"
Thread Thread Starter Forum Replies Last Post
Number of stock you can addin in MSN MoneyCentral Stock Quotes in Excel Weslee MS Office Support 2 4 Weeks Ago 11:16 AM
How can I add Check box in a Datagrid? Adrina_g Software Development 3 07-12-2009 11:22 AM
How to Export datagrid to pdf Integer Software Development 3 17-03-2009 08:58 PM
How can I get the row count from DataGrid? Shashikant Software Development 4 04-02-2009 11:47 PM
Add ComboBox in DataGrid in VB 6.0 Jateen Software Development 3 15-01-2009 06:31 PM


All times are GMT +5.5. The time now is 04:10 AM.