|
| |||||||||
| Tags: datagrid, procedure, vb dot net |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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 Best regards |
|
#2
| ||||
| ||||
| 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 |
|
#3
| |||
| |||
| 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 Code: myCommand. Parameters. Add ( "@ area", SqlDbType. NVarChar). Value = ComboBox_Area. SelectedItem Code: Sunday myCommand As New SqlCommand ( "dbo.PS_ACTION", Connect)
Sunday myReader As SqlDataReader Thank you again |
|
#4
| ||||
| ||||
| Re: Procedure datagrid stock - VB.Net
I said rather strange that there have to spend ... |
|
#5
| |||
| |||
| 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 |
|
#6
| ||||
| ||||
| 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. |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |