vangelisbb Δημοσ. 19 Μαρτίου 2013 Δημοσ. 19 Μαρτίου 2013 (επεξεργασμένο) Καλησπέρα σας Είχα ξεκινήσει να γράφω ένα πρόγραμμα στο σπίτι σε vb2010 με διάφορα queries σε mysql. Το πρόβλημά μου είναι πως το ίδιο solution που σπίτι μου δουλεύει, το έφερα στην δουλειά μου μπας και χαζέψω λίγο δεν μου δουλεύει . Βγάζει ο δείκτης ήταν εκτός ορίων του πίνακα με του που ξεκινάει το πρόγραμμα και στα πεδία που θα έπρεπε να δείχνει κάποια στοιχεία που τραβά από την βάση είναι κενά. Να σας πληροφορήσω πως η σχέση μου με την vb είναι εντελώς ερασιτεχνική οποιαδήποτε βοήθεια είναι καλοδεχούμενη. Παρακάτω παραθέτω τον κώδικα Ευχαριστώ Imports SystemImports System.XmlImports System.IOImports FSUIPCImports MySql.DataImports MySql.Data.MySqlClientImports System.Text.RegularExpressionsPublic Class frm_home 'Conection string Public dbstr As String = "Server=Myserver;database=Mydatabase;uid=dbusername;pwd=dbpass" Public dbcon As New MySqlConnection(dbstr) Dim strquery As String = "" Dim mysqlcmd As MySqlCommand Dim dr As MySqlDataReader Public dbadapter As New DataTable Private Sub frm_home_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'All the routines and functions that need to startup when form loads readpass() OpenFSUIPC() dbocon() pilotinfo() pireprow() End Sub Private Sub pireprow() 'Display all pireps in a Datagrid Dim id As String = lblid.Text Dim da As New MySqlDataAdapter("SELECT submitdate, flightnum, depicao, arricao, flighttime from phpvms_pireps WHERE pilotid='" & id & "'", dbcon) Dim dt As New DataTable da.Fill(dt) pirepgrid.DataSource = dt End Sub Private Sub pilotinfo() 'Pilot Profile Dim id As String = lblid.Text Dim totalhours As String Dim transferhours As String Dim totalhour As String 'strquery = "SELECT * FROM phpvms_pilots WHERE pilotid='gsa108'" strquery = "SELECT * FROM phpvms_pilots WHERE pilotid='" & id & "'" mysqlcmd = New MySqlCommand(strquery, dbcon) dbcon.Open() dr = mysqlcmd.ExecuteReader While dr.Read txtid.Text = dr.Item("code") & dr.Item("pilotid") txtname.Text = dr.Item("lastname") & Space(1) & dr.Item("firstname") txtemail.Text = dr.Item("email") txthub.Text = dr.Item("hub") txtflights.Text = dr.Item("totalflights") totalhours = dr.Item("totalhours") transferhours = dr.Item("transferhours") totalhour = (totalhours + transferhours) txthours.Text = totalhour End While dr.Close() dbcon.Close() End Sub Public Sub dbocon() 'Pilot information to display in form Try 'from saved xml Dim username As String = lblusername.Text Dim str() As String Dim str2 As String = username 'V airline 3 letter icao due to only number in db str = Regex.Split(str2, "GSA") Dim exusername As String = str(1) lblid.Text = str(1) Dim id As String = lblid.Text 'strquery = "SELECT * FROM phpvms_pilots WHERE pilotid='gsa108'" strquery = "SELECT * FROM phpvms_pilots WHERE pilotid='" & id & "'" mysqlcmd = New MySqlCommand(strquery, dbcon) dbcon.Open() dr = mysqlcmd.ExecuteReader While dr.Read lblpilotname.Text = dr.Item("lastname") & Space(1) & dr.Item("firstname") lblprank.Text = dr.Item("rank") End While dr.Close() dbcon.Close() Catch ex As Exception MsgBox("Something Went Wrong1" & ex.Message) End Try End Sub Public Sub OpenFSUIPC() Try ' Attempt to open a connection to FSUIPC (running on any version of Flight Sim) FSUIPCConnection.Open() ' Opened OK so disable the Connect button Me.btnconnect.Enabled = False lblfsuipcstatus.Text = "Conected" lblfsuipcstatus.ForeColor = Color.Green ' and start the timer ticking to drive the rest of the application Me.Timer1.Interval = 200 Me.Timer1.Enabled = True ' Set the AI object Catch ex As Exception ' Badness occurred - show the error message lblfsuipcstatus.Text = "Disconected" lblfsuipcstatus.ForeColor = Color.Red End Try End Sub Public Sub readpass() Dim username As String 'check if file myxml.xml is existing If (IO.File.Exists("c:\pass.xml")) Then 'create a new xmltextreader object 'this is the object that we will loop and will be used to read the xml file Dim document As XmlReader = New XmlTextReader("c:\pass.xml") 'loop through the xml file While (document.Read()) Dim type = document.NodeType 'if node type was element If (type = XmlNodeType.Element) Then 'if the loop found a <FirstName> tag If (document.Name = "Username") Then lblusername.Text = document.ReadInnerXml.ToString() lblusername.Font = New Font(lblusername.Font, FontStyle.Bold) username = document.ReadInnerXml.ToString() document.Close() End If End If End While Else End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Try Catch exFSUIPC As FSUIPCException If exFSUIPC.FSUIPCErrorCode = FSUIPCError.FSUIPC_ERR_SENDMSG Then ' Send message error - connection to FSUIPC lost. ' Show message, disable the main timer loop and relight the ' connection button: ' Also Close the broken connection. Me.Timer1.Enabled = False Me.btnconnect.Enabled = True FSUIPCConnection.Close() lblfsuipcstatus.Text = "disconected" lblfsuipcstatus.ForeColor = Color.Red Else ' not the disonnect error so some other baddness occured. ' just rethrow to halt the application Throw exFSUIPC End If End Try End SubEnd Class Επεξ/σία 20 Μαρτίου 2013 από vangelisbb
Προτεινόμενες αναρτήσεις
Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε
Πρέπει να είστε μέλος για να αφήσετε σχόλιο
Δημιουργία λογαριασμού
Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!
Δημιουργία νέου λογαριασμούΣύνδεση
Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.
Συνδεθείτε τώρα