Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.ComponentModel
Imports WealthLab
Public Class SQLConnector
Implements WealthLab.IWealthLabEOD3
Public Function CreateDataSource() As String Implements
IWealthLabEOD3.CreateDataSource
CreateDataSource =
"server=(local);database=ShareMarket;UID=sa;password=sa"
End Function
Public Sub FillSymbols(ByVal DSString As String, ByVal Symbols As
IWealthLabStrings3) Implements IWealthLabEOD3.FillSymbols
Dim myReader As SqlDataReader
Dim mySqlConnection As SqlConnection
Dim mySqlCommand As SqlCommand
mySqlConnection = New
SqlConnection("server=(local);database=ShareMarket;UID=sa;password=sa")
mySqlCommand = New SqlCommand("select CompanyName from
ScriptDetails", mySqlConnection)
Try
mySqlConnection.Open()
myReader = mySqlCommand.ExecuteReader()
Do While (myReader.Read())
Symbols.Add(myReader("nse_symbol").ToString())
Loop
Catch e As Exception
Console.WriteLine(e.ToString())
Finally
If Not (myReader Is Nothing) Then
myReader.Close()
End If
If (mySqlConnection.State = ConnectionState.Open) Then
mySqlConnection.Close()
End If
End Try
End Sub
Public Sub LoadSymbol(ByVal DSString As String, ByVal Symbol As
String, ByVal Bars As IWealthLabBars3, ByVal StartDate As Date, ByVal
EndDate As Date, ByVal MaxBars As Integer) Implements
IWealthLabEOD3.LoadSymbol
Dim myReader As SqlDataReader
Dim mySqlConnection As SqlConnection
Dim mySqlCommand As SqlCommand
Dim myDate As Date
Dim open As Double
Dim high As Double
Dim low As Double
Dim close As Double
Dim Volume As Integer
mySqlConnection = New
SqlConnection("server=(local);database=ShareMarket;UID=sa;password=sa")
mySqlCommand = New SqlCommand("select
[timestamp],[open],high,low,[close],tottrdqty from" + Symbol,
mySqlConnection)
Try
mySqlConnection.Open()
myReader = mySqlCommand.ExecuteReader()
Do While (myReader.Read())
myDate = myReader.GetDateTime(0)
open = myReader.GetDouble(1)
high = myReader.GetDouble(2)
low = myReader.GetDouble(3)
close = myReader.GetDouble(4)
Volume = myReader.GetInt32(5)
Bars.Add(myDate, open, high, low, close, Volume)
Loop
Catch e As Exception
Console.WriteLine(e.ToString())
Finally
If Not (myReader Is Nothing) Then
myReader.Close()
End If
If (mySqlConnection.State = ConnectionState.Open) Then
mySqlConnection.Close()
End If
End Try
End Sub
Public Function GetSecurityName(ByVal Symbol As String) As String
Implements IWealthLabEOD3.GetSecurityName
Dim myReader As SqlDataReader
Dim mySqlConnection As SqlConnection
Dim mySqlCommand As SqlCommand
mySqlConnection = New
SqlConnection("server=(local);database=ShareMarket;UID=sa;password=sa")
mySqlCommand = New SqlCommand("select nse_symbol from
ScriptDetails where nse_symbol = " + Symbol, mySqlConnection)
Try
mySqlConnection.Open()
myReader = mySqlCommand.ExecuteReader()
myReader.Read()
GetSecurityName = myReader("nse_symbol").ToString()
Catch e As Exception
Console.WriteLine(e.ToString())
Finally
If Not (myReader Is Nothing) Then
myReader.Close()
End If
If (mySqlConnection.State = ConnectionState.Open) Then
mySqlConnection.Close()
End If
End Try
Return GetSecurityName
End Function
End Class
The above code works fine with my Test class
However When i use it in wealth-lab it gives me the above error