You should make it a rule to include an ID field and make it a Primary Key when creating tables in a database.
And also include that in your SELECT statements.
That's why you get that message.
You should make it a rule to include an ID field and make it a Primary Key when creating tables in a database.
And also include that in your SELECT statements.
That's why you get that message.
Try setting the mdiparent of that second form to the MDI form.
mastersupplier.MdiParent = <name of mdi form>
Using a public servers date and time would require that the user of your program has an active internet connection, or is on a corporate network.
Both of which seems a bit hazardous if it's unknown.
What you could do is grab the systems date and time on first install/run and store it in the userspace of the program settings.
Then you could create a method that both checks the current date and calculate time passed, and also whether or not the systems date is less than the stored date indicating that the user has set the date back.
You simply call that method once on each execution.
(oops, missed that line) :)
First, why do you have this? strSelection = boConversionType.SelectedIndex.ToString()
Second.
I can see what the code does, but I can't see what strSelection is for.
If you select something from the combobox, the SelectedIndex will be > -1.
So, the Select Case statement works as it should.
You might wanna consider adding a Case Else for a default value in case you forget to select something.
What Select Case does is that it checks the value of whatever argument you put to it.
And then each Case checks if the value is this or that.
It's just a compressed version of If...Else If...Else If...Else If...Else...End If.
'These two examples perform the EXACT same task, but the first one is bit more bulkier
If cboConverstionType.SelectedIndex = 0 Then
strSelection = 25
Else If cboConverstionType.SelectedIndex = 1 Then
strSelection = 30
Else If cboConverstionType.SelectedIndex = 2 Then
strSelection = 35
End If
Select Case cboConverstionType.SelectedIndex
Case 0
strSelection = 25
Case 1
strSelection = 30
Case 2
strSelection = 35
End Select
This should have been posted in the ASP.NET forum.
You can't use MsgBox nor MessageBox on the web.
What you can do is use javascript with a vbscript popup box.
Here is a solution: http://www.delphifaq.com/faq/javascript/f1172.shtml
The link I gave you to a forum discussion at MSDN contained another link pointing to a project at CodeProject.
THAT project is written in C#.
Download it, open it in Visual Studio and compile it.
That will produce a library that you need to reference in your own project.
When that is done, you can use "Import Utilities.FTP".
By referencing the compiled C# library, you WILL get access to Utilities.FTP.
Follow these three steps...
1) Compile the FTP class library!
2) Create a reference to the DLL file in your own project!
The DLL file is located inside the \bin folder of THAT project.
3) Use: Imports Utilities.FTP.
It's that simple.
There is no need to look for and install any third-party software.
Help you do what?
If you have problem with this code, then perhaps you should ask your teacher about it.
I didn't quite catch that. But I assume that you want the filename to be displayed in a textbox on another form.
Use the saveFileDialog1.Filename property and store it in a class variable.
You can then pass that to the constructor, or custom property, of the second form.
You can use FtpWebRequest to transfer files to and from ftp servers.
Here is a FTP client library in C#.
And here is an example of how to use it.
All of these examples are perfectly good. When it comes down to it, it's a matter of preference for which way to go.
There really is no right or wrong method.
Close. Just switch it around a bit. Like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "PHP files (*.php)|*.php|All files (*.*)|*.*"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = saveFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then
' Code to write the stream goes here.
Dim myStream As Stream
'Create the file stream for writing
Dim stream As New StreamWriter(myStream)
'Write the initial PHP line
stream.WriteLine("<?PHP")
'Write the include statement for the header
stream.WriteLine("include_once('top.php'); ?>")
'And now, write out all the lines from the richtextbox
For Each line As String In RichTextBox1.Lines()
stream.WriteLine("echo """ & line & """;")
Next
'Write the include statement for the footer
stream.WriteLine("<?PHP include_once('down.php');")
'Write the end of the PHP file
stream.WriteLine("?>)")
'Flush and close the stream when you're done
stream.Flush()
stream.Close()
myStream.Close()
End If
End If
End Sub
If you format the text in the richtextbox with bullets and lists and what not, and wish to "export" the same layout to the php file. Then I cannot help you, because I don't know how.
It quite simple to write to a text file, in this case a php file.
There are many ways you could do this. This would work for me.
Private Sub CreatePHPFile()
'First, delete the existing (if any) file.
If File.Exists(Application.StartupPath & "\filename.php") Then
File.Delete(Application.StartupPath & "\filename.php")
End If
'Create the file stream for writing
Dim stream As New StreamWriter(Application.StartupPath & "\filename.php", False)
'Write the initial PHP line
stream.WriteLine("<?php")
'Write the include statement for the header
stream.WriteLine("include_once('top.php');")
'And now, write out all the lines from the richtextbox
For Each line As String In rtbTextBox.Lines()
stream.WriteLine("echo """ & line & """;")
Next
'Write the include statement for the footer
stream.WriteLine("include_once('down.php');")
'Write the end of the PHP file
stream.WriteLine("?>)")
'Flush and close the stream when you're done
stream.Flush()
stream.Close()
End Sub
As for bulleted text and any such formatting.
All you have to do is to insert any html tags before and after the For loop using the stream.WriteLine() method.
The tag for a bulleted list is this: <ul><li>text</li></ul>
Both would work for what you intend to do.
You could use two ArrayLists.
For each ArrayList as an item in another ArrayList.
The "outer" ArrayList contains the rows, and the "inner" ArrayList contains the columns.
Dim arrRows As New ArrayList
For Each row As DataRow In <datatable>.Rows
Dim arrCols As New ArrayList
arrCols.Items.Add(row("first column"))
arrCols.Items.Add(row("second column"))
arrCols.Items.Add(row("third column"))
arrCols.Items.Add(row("fourth column"))
'and so on
arrRows.Items.Add(arrCols)
Next
To access those rows and columns in the ArrayLists, you can do this.
For Each item As ArrayList in arrRows
variable1 = item(0)
variable2 = item(1)
variable3 = item(2)
variable4 = item(3)
Next
'Or this
someVariable1 = arrRows(0)(0) 'Retrieve the first "cell" in the first row
someVariable2 = arrRows(2)(3) 'Retrieve the fourth "cell" in the third row
Change this line:
cat.Create("Provider=Microsoft.ace.OLEDB.12.0;Data Source=C:\Customer\Customer.accdb")
to this:
cat.Create("Provider=Microsoft.ace.OLEDB.12.0;Data Source=C:\Customer\Customer.accdb:Database Password=<password>")
In your search method you're reading the query directly into a datatable, which you then use as a datasource for the datagridview.
But in the update method you're using a dataset as the source for the da.Update method.
The dataset has not been filled with a datatable named "Tracker".
I also noticed that you assign a databindingsource to the datagridview in the form load event.
But you're not using it.
Have you tried using HttpWebResponse.ResponseUri?
Dim response As HttpWebResponse
Dim resUri As String
response = request.GetResponse
resUri = response.ResponseUri.AbsoluteUri
Ok. I managed to get it to work.
Use the codes I gave you, but add one single line to the Student class.
In the method Add_Node_Student, add the line "kq.Name = sv._CODE".
The Find(key, True) method is looking for the NAME of the node.
Alright.
RemoveByKey seems to only remove nodes from the position in the tree where you call it.
Replace the line "liststudentTreeView.Nodes.RemoveByKey(key)" with this:
Dim node() As TreeNode = liststudentTreeView.Nodes.Find(key, True)
liststudentTreeView.Nodes.Remove(node(0))
I see your point.
Then a slight change might be in order. Try this:
Dim key As String
Dim arrUser As ListView.SelectedListViewItemCollection
arrUser = liststudentListView.SelectedItems
For Each item As ListViewItem In arrUser
key = item.Text
liststudentListView.Items.Remove(item)
liststudentTreeView.Nodes.RemoveByKey(key)
Next
This should remove the treenode containing the exact same student code as the item in the listview.
If the item has been added at the same place in both the TreeView and the ListView, then you can make a note of the index of the selected item in the ListView before you delete it.
You can then use that index to locate the corresponding node in the TreeView and delete that node.
Dim index As Integer
index = ListView1.SelectedIndices.Item(0)
ListView.SelectedItems.Item(0).Remove()
TreeView.Nodes.RemoveAt(index)
Enclose your code in a Try...Catch statement.
Private Sub aMethod()
Try
'Your code goes here
Catch ex As Exception
MessageBox.Show(ex.Message, "An error has occured")
End Try
End Sub
Most likely it's quite wise to read the FireBirdSQL FAQ.
http://www.firebirdfaq.org/faq19/
It's SQL, but you can execute SQL programmatically from VB.NET.
If you set pictureBox1.Image = Nothing
before setting the resized image, the picturebox will be cleared and the original image will not be there anymore.
Only the resized one.
I'm using a single method for resizing images in both directions.
It returns a BitMap object that you can use on wherever you like.
public BitMap ResizeBitMap(BitMap source, Size newSize)
{
//Get the source bitmap
BitMap bm_source = source;
//Create a bitmap for the result
BitMap bm_dest = new BitMap(newSize.Width, newSize.Height);
//Create a Graphics object for the resulting BitMap
Graphics gr_dest = Graphics.FromImage(bm_dest);
//Copy the source image into the destination bitmap
gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1);
//Return the result
return bm_dest;
}
Here is one way of how you can use it:
private void someMethod()
{
BitMap resizedImage = ResizeBitMap(loadedImage, new Size(loadedImage.Width * .9, loadedImage.Height * .9));
//Stick that resized bitmap anywhere you like it.
//For example a PictureBox
pictureBox1.Image = resizedImage;
}
Take another look at the connectionstring and pay close attention to the filename itself.
In a hurry I mistakenly switched some letters around in the extension.
So change "Contact.mbd" to "Contact.mdb".
So. What exactly does the exception say?
If the connectionstring is at fault, then the most probable culprit is the path to your database.
I inserted Application.StartupPath (the path from where your programs EXE file is executed), because I figured that's where your MDB file is located.
If the table that you want to save the data to is the same table that you use to populate the DataGridView, then I suggest that you use databinding to bind the DataGridView to a DataTable.
You can find several solutions for databinding right here on DaniWeb.
Every time that you make a change in the DataGridView, the DataTable will be updated to match those changes.
When you click the Save button, you can push those changes from the DataTable onto the database.
This is a very simple example of how to fetch, insert, update and delete data from a MS Access database.
By default you can also see how to connect to it.
However, consider that a contact database will eventually contain several records, you should also be able to use this and figure out a way to browse between them.
Imports System
Imports System.Data.OleDb
Public Class Form1
Private connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\Contact.mbd; User Id=admin; Password=;"
Private intID As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FetchData()
End Sub
Private Sub cmdNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNew.Click
InsertData()
End Sub
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
UpdateData()
End Sub
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
DeleteData()
End Sub
Private Sub FetchData()
Dim con As New OleDbConnection(connString)
Dim com As OleDbCommand = Nothing
Dim reader As OleDbDataReader = Nothing
Try
con.Open()
com = New OleDbCommand("SELECT * FROM contact", con)
reader = com.ExecuteReader(CommandBehavior.CloseConnection)
If reader.HasRows Then
intID = reader("ID")
If Not IsDBNull(reader("Name")) Then txtName.Text = reader("Name")
If Not IsDBNull(reader("Company")) Then txtName.Text = reader("Company")
If Not IsDBNull(reader("Contact")) Then txtName.Text = reader("Contact")
End If
reader.Close()
Catch ex As Exception
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
Private Sub InsertData()
Dim con As New OleDbConnection(connString)
Dim com As OleDbCommand = Nothing
Try
con.Open()
com = New OleDbCommand("INSERT INTO contact (Name, …
Swing a cat. :)
Although. If there's even a slight chance that a computer might be used by more than one user, you should seriously consider using the CommonApplicationData folder.
Do you remember the connection string I gave you in your previous post "Need Help"?
Try using that one instead.
If I recall correctly, the constant DATA_SOURCE already contains "data source=JAKE-PC\SQLEXPRESS", so what you have done in your StingBuilder is declare the data source twice.
It's redundant, and causes errors.
And, the format of your connection string is targeted towards MSSQL 2005/2008.
Try using "Integrated Security=SSPI" instead of "trusted_connection=yes;".
Well. Having tried my luck on relying purely on the Designer myself, I know that sometimes you can miss or forget certain details.
By doing the coding yourself, you can get a clearer view of what's going on.
Not to dismiss the Designer entirely, most of the time it saves the day.
But sometimes you need to get your hands dirty and do it yourself. :)
Ok. How about this.
This always works for me.
I'm manually creating and adding each column in the forms Load event, instead of using the Designer.
That way I get more control on what goes where, and how.
Imports System
Imports System.Data.SqlClient
Public Class Form1
Private connString As String = "Data Source=<computerName>\SQLEXPRESS; Initial Catalog=<database>;Integrated Security=SSPI;"
Private bindingSource1 As New BindingSource
Private myDA As SqlDataAdapter
Private mydataset As DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mydataset = New DataSet()
DataGridViewSearchExist.AutoGenerateColumns = False
Dim clmID As New DataGridViewTextBoxColumn
clmID.HeaderText = "ID"
clmID.DataPropertyName = "t_id"
DataGridViewSearchExist.Columns.Add(clmID)
Dim clmFirstName As New DataGridViewTextBoxColumn
clmFirstName.HeaderText = "First Name"
clmFirstName.DataPropertyName = "firstName"
DataGridViewSearchExist.Columns.Add(clmFirstName)
Dim clmLastName As New DataGridViewTextBoxColumn
clmLastName.HeaderText = "Last Name"
clmLastName.DataPropertyName = "lastName"
DataGridViewSearchExist.Columns.Add(clmLastName)
Dim clmRentPaid As New DataGridViewTextBoxColumn
clmRentPaid.HeaderText = "Rent Paid"
clmRentPaid.DataPropertyName = "rentPaid"
DataGridViewSearchExist.Columns.Add(clmRentPaid)
Dim clmDatePaid As New DataGridViewTextBoxColumn
clmDatePaid.HeaderText = "Date Paid"
clmDatePaid.DataPropertyName = "datePaid"
DataGridViewSearchExist.Columns.Add(clmDatePaid)
Dim clmPropRef As New DataGridViewTextBoxColumn
clmPropRef.HeaderText = "Property Reference"
clmPropRef.DataPropertyName = "propRef"
DataGridViewSearchExist.Columns.Add(clmPropRef)
Dim clmRentDue As New DataGridViewTextBoxColumn
clmRentDue.HeaderText = "Rent Due"
clmRentDue.DataPropertyName = "rentDue"
DataGridViewSearchExist.Columns.Add(clmRentDue)
DataGridViewSearchExist.DataSource = bindingSource1
End Sub
Private Sub RadTextBoxTenantIdSearchExist_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadTextBoxTenantIdSearchExist.TextChanged
BindData()
End Sub
Private Sub BindData()
Try
myDA = New SqlDataAdapter("SELECT t_id, firstName, lastName, rentPaid, datePaid, propRef, rentDue FROM payments WHERE t_id = '" & RadTextBoxTenantIdSearchExist.Text & "'", connString)
Dim builder As SqlCommandBuilder = New SqlCommandBuilder(myDA)
myDA.Fill(mydataset, "payments")
bindingSource1.DataSource = mydataset.Tables("payments")
Catch ex As Exception
bindingSource1.DataSource = Nothing
End Try
End Sub …
First, move the line DataGridViewSearchExist.DataSource = bindingSource1
to the forms Load event.
You only need to assign that once.
And make sure that the fields "t_id, firstName, lastName, rentPaid, datePaid, propRef, rentDue" are still tied to each of the columns you have created in the DataGridView.
Each field name are to be typed into each columns DataPropertyName property.
I would render a guess as to that might be the main reason for why it stopped working.
If you wanna move or copy files from one location to another using your program, there are easier ways than using FileStream.
Imports System.IO
Private Sub FileCopy()
Dim strFileSource As String = "C:\Temp\sourceFile.txt"
Dim strFileDestination As String = "C:\Temp\destinationFile.txt"
File.Copy(strFileSource, strFileDestination)
End Sub
Private Sub FileMove()
Dim strFileSource As String = "C:\Temp\sourceFile.txt"
Dim strFileDestination As String = "C:\Temp\destinationFile.txt"
File.Move(strFileSource, strFileDestination)
End Sub
Private Sub CopyMoveMultipleFiles()
Dim strSourceDirectory As String = "C:\Temp"
Dim strDestinationDirectory As String = "C:\SecondaryTemp"
Dim di As New DirectoryInfo(strSourceDirectory)
'To copy files
For Each fi As FileInfo In di.GetFiles
fi.CopyTo(strDestinationDirectory & "\" & fi.Name)
Next
'To move files
For Each fi As FileInfo In di.GetFiles
fi.MoveTo(strDestinationDirectory & "\" & fi.Name)
Next
End Sub
I'm starting to see a pattern here.
Try this connection string, without using a StringBuilder.
_connectionString = "Data Source=JAKE-PC\SQLEXPRESS; Inital Catalog=Ticketing; Integrated Security=SSPI"
And the connection string cannot be passed as the name of a Stored Procedure.
It has to be the name of an existing Stored Procedure in the database server.
Sure, you can have your own column headers.
However (and I must refer to others on this one) I don't think that the ColumnAdded event is triggered AFTER the databind is done.
First, just add and name the columns in the Designer, as you tried to do.
But you MUST also enter the name of the database field in the DataPropertyName property for each column.
When that is done, go to the form load event and add this line as the very first line.
DataGridViewSearchExist.AutoGenerateColumns = False
You should consider moving that code onto a button click event.
Otherwise the query will be fired for every keystroke you use in the textbox.
And you are very close to the solution, my friend. :)
Notice my lack of use of the SqlConnection object. It will work anyway, because the SqlDataAdapter will take care of connecting to the database. If provided with the connection string.
The SqlCommandBuilder will help take care of creating INSERT, UPDATE and DELETE statements for you.
Private bindingSource1 As New BindingSource
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
AuthorsGridView.DataSource = bindingSource1
End Sub
Private Sub TextBoxId_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxIdSearchExist.TextChanged
Try
da = New SqlDataAdapter("SELECT * FROM pay WHERE t_id = '" & tId.Text & "'", <your connection string>)
Dim builder As New SqlCommandBuilder(da)
da.Fill(ds, "pay") 'Needs to be the name of the source table
'I don't know what GetData(queryString) is for, so I'm ignoring it
If ds.Tables.Count > 0 Then
bindingSource1.DataSource = ds.Tables(0)
Else
MessageBox.Show("No results found in database.")
End If
Catch ex As Exception
MessageBox.Show("Unable to connect to database, or an error occured.")
End Try
End Sub
If you want instant storing of the forms position when you move it, you need to use the MouseDown, MouseMove and MouseUp events.
'First a private member variable
Private bIsMouseDown As Boolean = False
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
'First check to see which mousebutton was pressed
If e.Button = Windows.Forms.MouseButtons.Left Then
'Then check to see if the location of the mouse is within the region of the form
If e.Location.X > Me.Bounds.Left AndAlso e.Location.X < Me.Bounds.Right _
AndAlso e.Location.Y > Me.Bounds.Top AndAlso e.Location.Y < Me.Bounds.Bottom Then
bMouseDown = True
End If
End If
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If bMouseDown Then
MyX = Me.Location.X
MyY = Me.Location.Y
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
bMouseDown = False
End Sub
You need to grab the handle of the application for which you want to save the document.
In order to achieve this, you need to use Windows API to grab and perform.
''' A couple of APIs
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindow(ByVal lpcClassName As String, ByVal lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowByClass( _
ByVal lpClassName As String, _
ByVal zero As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowByCaption( _
ByVal zero As IntPtr, _
ByVal lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
ByVal childAfter As IntPtr, _
ByVal lclassName As String, _
ByVal windowTitle As String) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Function SendNotifyMessage( _
ByVal hWnd As IntPtr, _
ByVal msg As UInteger, _
ByVal wParam As UIntPtr, _
ByVal lParam As IntPtr _
) As Boolean
End Function
''' General methods
Const BM_CLICK As Uinteger = &HF5
Dim WindowHandle As IntPtr
Dim ButtonHandle As IntPtr
'First grab the actual window of the application
WindowHandle = FindWindowByCaption(IntPtr.Zero, "Caption of Notepad window")
'Second, grab the desired function/button within the window/application, in this case the Save button
ButtonHandle = FindWindowEx(WindowHandle, 0, "Button", "&Save")
'Send a message to the grabbed window/button to perform an action, in this case click the Save button
SendNotifyMessage(ButtonHandle, BM_CLICK, 0, 0)
You could use the method GetProcessesByName in order to determine if a certain process is running.
It returns an array of processes containing all instances of a certain named process, for example "wmplayer".
If the Length of the array is greater than 0, then that particular process is running.
This snippet also eliminates the need for ListBoxes and things like that.
If GetProcesses("wmplayer") > 0 Then
textbox.Text = textbox.Text & Environment.NewLine & " -> Windows Media Player"
End If
Private Function GetProcesses(nameOfProcess As String) As Integer
Dim namedProcess As Process() = Process.GetProcessesByName(nameOfProcess)
Return namedProcess.Length
End Function
My first thought is that when you deploy the program, the CreateDirectory method may not have sufficient rights to create a folder on the hard drive, and thus skips the call to InitiateDownload.
Have you tried running it as Administrator?
My second thought is that you may wish to add a Try...Catch statement in both the FileDownload_Load event and in the InitiateDownload method.
That way you can track where things goes sideways, if that is the case.
Other than that, your code is spot on. :)
In addition to adding the reference to Microsoft Outlook 14, make sure that you also import the namespace Microsoft.Office.Interop.
Then you can use this code to create a mail message.
Dim oApp As New Outlook.Application()
Dim oMsg As Outlook.MailItem
oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oMsg.To = "reciever@domain.com"
oMsg.Subject = "mail subject"
oMsg.Body = "simple mail body text"
'' OR
'oMsg.HTMLBody = "html mail body text"
oMsg.Send()
'Optionally also use:
'oMsg.Display()
Yes, I would revise that code into something like this.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim playerdrivers As New ArrayList
Dim destination As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\f1data\bin\array.txt"
Dim FileReader1 As New StreamReader(destination)
Dim Contents1 As String
Dim index As Integer = 0
While FileReader1.Peek <> -1
Contents1 = FileReader1.ReadLine
Dim array As New ArrayList
array.AddRange(Contents1.Split(","))
playerdrivers.Add(array)
End While
FileReader1.Close()
After that you can easily access each player and driver using almost the same method as you intended:
playerdrivers(0).Item(0) - playerdrivers(0).Item(5)
playerdrivers(1).Item(0) - playerdrivers(1).Item(5)
Yes it is.
But you still need to explicitly tell the query which field to use.
cmd.CommandText = "INSERT INTO " & combobox.SelectedItem & " (<field>) VALUES ('" & textbox.Text & "')"
Why not convert the method into a function that returns a string.
And then enclose the code in a Try...Catch statement.
If the code should fail, then you can return the .ToString() of the exception object and examine what went wrong.
Otherwise you just return an empty string.