Many thanks to Mumbles for his great tutorial, i have followed it so that i now have a working form.
However, i would like to try and save the markets information into a database. I have spent the last 3 nights reading, reading and more reading about datasets, datatables, databases, tableadapters, binding sources and i have got totally and utterly confused.
My first experience of any type of programming was 10 days ago when i first saw this thread and then thought i'd give it a go
I have followed the tutorial where it teaches you how to display the Markets information in a datagridview. I have changed my application so it shows all the columns that the 'marketdata' output provides in my datagridview.
I understand that the matchdata object holds the information i need to get to my database.
I spent days trying to use the tableadapters and the data sources within vb 2010 but tonight learnt that they are for typed datasets. Am i right in assuming that i have to create an untyped dataset that the datatable dtmarkets sits in, and therefore i am unable to connect the database so it shoes in a dataset that appears in the solution explorer?
Could anyone have a look at my code below and see where i am going wrong, or just give me a gentle push in the right direction as i am very keen to learn how to do stuff myself? My Sql connection works fine, i have tested this by putting in a breakpoint at the 'dtMarkets.Rows.Add(matchdata)' line and then checking the connection state and it is open. At that moment after i havei clicked on my SqlConnect button the textbox shows that the header is ok and the errorcode ok. The 'matchdata' object has 16 fields of data within it as it should do, but when i check the database table (tblMarkets) in my database there is no data in it?
However, i would like to try and save the markets information into a database. I have spent the last 3 nights reading, reading and more reading about datasets, datatables, databases, tableadapters, binding sources and i have got totally and utterly confused.
My first experience of any type of programming was 10 days ago when i first saw this thread and then thought i'd give it a go

I have followed the tutorial where it teaches you how to display the Markets information in a datagridview. I have changed my application so it shows all the columns that the 'marketdata' output provides in my datagridview.
I understand that the matchdata object holds the information i need to get to my database.
I spent days trying to use the tableadapters and the data sources within vb 2010 but tonight learnt that they are for typed datasets. Am i right in assuming that i have to create an untyped dataset that the datatable dtmarkets sits in, and therefore i am unable to connect the database so it shoes in a dataset that appears in the solution explorer?
Could anyone have a look at my code below and see where i am going wrong, or just give me a gentle push in the right direction as i am very keen to learn how to do stuff myself? My Sql connection works fine, i have tested this by putting in a breakpoint at the 'dtMarkets.Rows.Add(matchdata)' line and then checking the connection state and it is open. At that moment after i havei clicked on my SqlConnect button the textbox shows that the header is ok and the errorcode ok. The 'matchdata' object has 16 fields of data within it as it should do, but when i check the database table (tblMarkets) in my database there is no data in it?
Code:
Private Sub bSqlConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bSqlConnect.Click
sqlComm.Connection = sqlConn 'Connection string and command string set as public in Unpack module
sqlConn.Close()
sqlConn.Open()
' Set Dataset and datatable
Dim dsBetfair As DataSet = New DataSet("MarketDetails")
Dim dtMarkets As DataTable = dsBetfair.Tables.Add("Markets")
Try
With dtMarkets.Columns
.Add("MarketID", GetType(System.String))
.Add("MarketName", GetType(System.String))
.Add("MarketType", GetType(System.String))
.Add("MarketStatus", GetType(System.String))
.Add("EventDate", GetType(System.DateTime))
.Add("MenuPath", GetType(System.String))
.Add("EventHierachy", GetType(System.String))
.Add("BetDelay", GetType(System.String))
.Add("ExchangeID", GetType(System.String))
.Add("ISO3CountryCode", GetType(System.String))
.Add("LastRefresh", GetType(System.DateTime))
.Add("NoRunners", GetType(System.String))
.Add("NoWinners", GetType(System.String))
.Add("TtlAmountMatched", GetType(System.Double))
.Add("BspMarket", GetType(System.Boolean))
.Add("TurningInPlay", GetType(System.Boolean))
End With
Print("*** Data to SQL ***")
Dim oMarketsReq As New BFUK.GetAllMarketsReq
Dim oMarketsResp As BFUK.GetAllMarketsResp
Dim matchdata(15) As Object
With oMarketsReq
.header = oHeaderUK()
ReDim .eventTypeIds(0) : .eventTypeIds(0) = 7 'For Horse Racing
ReDim .countries(1) : .countries(0) = "GBR" : .countries(1) = "ZAF"
.fromDate = Today.AddDays(0)
.toDate = Today.AddDays(1)
End With
oMarketsResp = BetFairUK.getAllMarkets(oMarketsReq) 'Call the UK API
With oMarketsResp
Checkheader(.header)
Print("ErrorCode = " & .errorCode.ToString)
If .errorCode = BFUK.GetAllMarketsErrorEnum.OK Then
Dim AllMarkets As New UnpackAllMarkets(.marketData)
With AllMarkets
For i = 0 To .marketData.Length - 1
With .marketData(i)
matchdata(0) = .marketId
matchdata(1) = .marketName
matchdata(2) = .marketType
matchdata(3) = .marketStatus
matchdata(4) = .eventDate.ToLocalTime
matchdata(5) = .menuPath
matchdata(6) = .eventHeirachy
matchdata(7) = .betDelay
matchdata(8) = .exchangeId
matchdata(9) = .countryCode
matchdata(10) = .lastRefresh
matchdata(11) = .noOfRunners
matchdata(12) = .noOfWinners
matchdata(13) = .totalAmountMatched
matchdata(14) = .bspMarket
matchdata(15) = .turningInPlay
dtMarkets.Rows.Add(matchdata)
Dim fillQueryString As String = _
"SELECT marketId, marketName, marketType, marketStatus, eventDate, menuPath, eventHierachy, betDelay, exchangeId," & _
"iso3CountryCode, lastRefresh, noOfRunners, noOfWinners, totalAmountMatched, bspMarket, turningInPlay FROM dbo.tblMarkets"
Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(fillQueryString, sqlConn)
adapter.Fill(dsBetfair, "tblMarkets")
End With
Next
End With
End If
End With
Catch ex As Exception
MessageBox.Show("Failed to connect to data source")
sqlConn.Close()
End Try
End Sub


Using .layamount and .backamount

Comment