I have a SQL table in a program which I import the lottery CSV file off the internet. I also delete the data in the table before importing the file. However, when I run the project or if I publish it. Any imports or delete are not seen when I open a form with a data grid view. I have to stop debugging the project or if I am running the program close it down. When I am debugging it again or start the program the changes are there.
I know the the data mdf are in two places when I working on the project. That not true if I published it, or is it?
Where Am I going wrong.
Delete code
Private Sub ClearLotteryTableToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearLotteryTableToolStripMenuItem.Click
Dim objConnection As SqlConnection = New _
SqlConnection()
objConnection.ConnectionString = _
"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\ellip\My Documents\
VB\My Work\VBproagam\DatabaseWork\LotteryVB1\Lotterytest 1\Lotterytest1\LotteryTestDatabase.mdf;" & _
"Integrated Security=True;Asynchronous Processing=true;Connect Timeout=30;User Instance=True"
Dim objCommand As SqlCommand = New SqlCommand()
objConnection.Open()
objCommand.Connection = objConnection
objCommand.CommandText = "DELETE FROM LotteryNumbers"
objCommand.ExecuteNonQuery()
objConnection.Close()
Me.LotteryNumbersTableAdapter.Update(Me.LotteryTes tDatabaseDataSet.LotteryNumbers)
'TODO: This line of code loads data into the 'LotteryTestDatabaseDataSet.LotteryNumbers' table. You can move, or remove it, as needed.
Me.LotteryNumbersTableAdapter.Fill(Me.LotteryTestD atabaseDataSet.LotteryNumbers)
End Sub
Load Form code.
Private Sub frmLotteryNumbers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LotteryTestDatabaseDataSet.GetChanges()
LotteryNumbersDataGridView.Refresh()
loadNumbersLotteryTable()
End Sub
Public Sub loadNumbersLotteryTable()
' Change header text
LotteryNumbersDataGridView.Columns(10).Width = 265
LotteryNumbersDataGridView.Columns(0).HeaderText = "Draw Date"
LotteryNumbersDataGridView.Columns(1).HeaderText = "Ball One"
LotteryNumbersDataGridView.Columns(2).HeaderText = "Ball Two"
LotteryNumbersDataGridView.Columns(3).HeaderText = "Ball Three"
LotteryNumbersDataGridView.Columns(4).HeaderText = "Ball Four"
LotteryNumbersDataGridView.Columns(5).HeaderText = "Ball Five"
LotteryNumbersDataGridView.Columns(6).HeaderText = "Ball Six"
LotteryNumbersDataGridView.Columns(7).HeaderText = "Bonus Ball"
LotteryNumbersDataGridView.Columns(8).HeaderText = "Ball Set"
LotteryNumbersDataGridView.Columns(9).HeaderText = "Machine"
LotteryNumbersDataGridView.Columns(10).HeaderText = "Draw Data"
' Declaire and set alternating row style
Dim objAlternatingCellStyle As New DataGridViewCellStyle()
objAlternatingCellStyle.BackColor = Color.LightSkyBlue
LotteryNumbersDataGridView.AlternatingRowsDefaultC ellStyle = objAlternatingCellStyle
Me.LotteryNumbersTableAdapter.Update(Me.LotteryTes tDatabaseDataSet.LotteryNumbers)
'TODO: This line of code loads data into the 'LotteryTestDatabaseDataSet.LotteryNumbers' table. You can move, or remove it, as needed.
Me.LotteryNumbersTableAdapter.Fill(Me.LotteryTestD atabaseDataSet.LotteryNumbers)
Dim newColumn As DataGridViewColumn
newColumn = Me.LotteryNumbersDataGridView.Columns(0)
Me.LotteryNumbersDataGridView.Sort(newColumn, ComponentModel.ListSortDirection.Descending)
End Sub