I'm a VB6 developer myself mostly, and am just starting with .Net
I've no formal training in .Net whatsoever, but have just forged ahead and tried to write an application.
Is there anything really wrong or stupid with this app so far?
i.e. dodgy coding practices that have carreid over from vb6 etc. ?
Form1.vb
VB Code:
Imports System.Data.SqlClient Public Class Form1 Inherits System.Windows.Forms.Form Private WithEvents mySqlConnection As sqlConnection Private mySQLReader As SqlDataReader Private blnHaveCleared As Boolean = False Private lngLineCount As Long, lngCurrLine As Long Private colHeaders As New Collection() #Region " Windows Form Designer generated code " . . . just adds a listbox and a button #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click mySqlConnection = New SqlConnection("Integrated Security=SSPI;Persist Security Info=False;User ID=usrShop;Initial Catalog=dbShop;Data Source=JAMIETOSH;") mySqlConnection.Open() End Sub Private Sub mySqlConnection_StateChange(ByVal sender As Object, ByVal e As System.Data.StateChangeEventArgs) Handles mySqlConnection.StateChange If e.CurrentState = ConnectionState.Open Then Dim intFileNumber As Integer = FreeFile(), strFileContent As String Dim strArr() As String, strFields() As String Dim strHeaders() As String, lngColIndex As Long, i As Long FileOpen(intFileNumber, "c:\test.txt", OpenMode.Input) strFileContent = InputString(intFileNumber, LOF(intFileNumber)) strArr = Split(strFileContent, vbCrLf) lngLineCount = UBound(strArr) For lngCurrLine = 0 To 100 'lngLineCount If Not lngCurrLine = 0 Then strFields = Split(strArr(lngCurrLine), vbTab) sqlAddHeaders(strFields(1), strFields(0), mySqlConnection) 'sqlAddProductToDB(strArr(lngCurrLine), mySqlConnection) End If Next FileClose(intFileNumber) mySqlConnection.Close() End If End Sub End Class




Reply With Quote