PeterBaileyUk
asked on
dataviewGrid in vb.net
I have a form see attached, the user makes a selection and i would like the dataview grid to display different data based on the choice made. I have made a number of stored procedures but i dont know how to change the binding to the different sp's.
my grid is named DataGridViewStringDescAll
my grid is named DataGridViewStringDescAll
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What I found was that I had so many adaptors created that the whole thing fell apart, am I right in thinking that if I create one dataset, which has all the available stored procedures that then I can call which ever stored procedure i want but with only the one dataset.
Ive attached a screen shot where it all fell apart, i think its because i added to mant data sources which here the same thing.
Ive gone back to the start.
you can see the empty grid now with the option box.
thats why i didnt post code as it was more advisory at the moment.
barry.JPG
Ive attached a screen shot where it all fell apart, i think its because i added to mant data sources which here the same thing.
Ive gone back to the start.
you can see the empty grid now with the option box.
thats why i didnt post code as it was more advisory at the moment.
barry.JPG
ASKER
now the interface
ee.JPG
ee.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok so that's great, that I never knew. So using your 41734482 I can have one grid and call params to different stored procedures as required.
ASKER
ok I am going in little steps, I have 3 functions but it looks like your function 41734482 can take place of all these 3 but i am not 100% sure how to put in the logic to supply the correct parameter based on the option chosen as you can see in my functions its determining the parameter values in the first if statements of each 3
do I need to put in each of these the cmd.CommandTimeout = 0 or does that go somewhere else globally.
do I need to put in each of these the cmd.CommandTimeout = 0 or does that go somewhere else globally.
Public Function GetBulkDataStringsSuperVehCat() As DataTable
Dim StrProcName As String
Dim StrVehSupCat As String
If OpShortDescCarsLcvOthersAll.Checked = True Then
StrVehSupCat = "CarLcvOthers"
End If
If OpShortDescBikesQuadsAll.Checked = True Then
StrVehSupCat = "BikesQuads"
End If
dtWords = New DataTable
Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString
StrProcName = "usp_GetBulkDescStringsSuper"
Using conn As New SqlConnection(connectionString)
'Using cmd As New SqlCommand("usp_GetWords", conn)
Using cmd As New SqlCommand(StrProcName, conn)
cmd.CommandType = CommandType.StoredProcedure
conn.Open()
cmd.Parameters.AddWithValue("@VCatSuper", StrVehSupCat)
Dim reader As SqlDataReader = cmd.ExecuteReader()
dtWords.Load(reader)
End Using
End Using
Return dtWords
End Function
Public Function GetBulkDataStringsVehCat() As DataTable
Dim StrProcName As String
Dim StrVehCat As String
If OpShortDescCarsAll.Checked = True Then
StrVehCat = "Car"
End If
If OpShortDescBikesAll.Checked = True Then
StrVehCat = "Motorcycle"
End If
If OpShortDescLcvAll.Checked = True Then
StrVehCat = "Lcv"
End If
If OpShortDescOthersAll.Checked = True Then
StrVehCat = "Others"
End If
dtWords = New DataTable
Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString
StrProcName = "usp_GetBulkDescStringsVehCat"
Using conn As New SqlConnection(connectionString)
Using cmd As New SqlCommand(StrProcName, conn)
cmd.CommandType = CommandType.StoredProcedure
conn.Open()
'cmd.Parameters.AddWithValue("@Client", StrClient)
cmd.Parameters.AddWithValue("@VCategory", StrVehCat)
Dim reader As SqlDataReader = cmd.ExecuteReader()
dtWords.Load(reader)
End Using
End Using
Return dtWords
End Function
Public Function GetBulkDataStrings() As DataTable
Dim StrProcName As String
dtWords = New DataTable
Dim connectionString As String = ConfigurationManager.ConnectionStrings("Dictionary").ConnectionString
StrProcName = "usp_GetBulkDescStrings"
Using conn As New SqlConnection(connectionString)
Using cmd As New SqlCommand(StrProcName, conn)
cmd.CommandType = CommandType.StoredProcedure
conn.Open()
'cmd.Parameters.AddWithValue("@Client", StrClient)
Dim reader As SqlDataReader = cmd.ExecuteReader()
dtWords.Load(reader)
End Using
End Using
Return dtWords
End Function
ASKER
ive split the points as both responses have fixed the situation.
Open in new window