give thisread
Click Here

This is the structure of a CSV File yours loads into a datagrid but the info is all lumped together

EXTENSION,DESCRIPTION,EXECUTABLE_PATH
.001,None,C:\Program Files\7-Zip\7z.exe
.323,H.323 Internet Telephony,rundll32.exe
.386,Virtual device driver,NO DEFAULT PROGRAM SET
.3g2,3GPP2 Movie,C:\Program Files\QuickTime\QuickTimePlayer.exe
.3gp,3GPP Movie,C:\Program Files\QuickTime\QuickTimePlayer.exe
.3gp2,3GPP2 Movie,C:\Program Files\QuickTime\QuickTimePlayer.exe
.3gpp,3GPP Movie,C:\Program Files\QuickTime\QuickTimePlayer.exe
.669,Composer 669 Module,NO DEFAULT PROGRAM SET
.7z,None,C:\Program Files\7-Zip\7z.exe
.aa,None,NO DEFAULT PROGRAM SET
.aac,None,C:\Program Files\QuickTime\QuickTimePlayer.exe
.aax,None,NO DEFAULT PROGRAM SET

Anyway try the following code after you load the datatable

 For i As Integer = 0 To 9
     ds.Tables(0).Rows(i).Delete()
 Next

  ds.Tables(0).AcceptChanges()

It should remove all the rows above the START row.

Please post some of your CSV file. We do n ot know what your column names are or what your data looks like.

As for your wanting rows 98 - 156 use the following.
cnt is an integer variable: cnt = objDataset.Tables(0).Rows.Count - 1

 For i As Integer = cnt To 0 Step -1
            If i < 98 Or i > 156 Then
                objDataset1.Tables(0).Rows(i).Delete()

            End If
        Next
        ds.Tables(0).AcceptChanges()

I would like to see a sample of your csv file the first 3 rows should be enough.

Where line of code caused "No value given for one or more required parameters. i got this error sir" error?

Does your DataAdapter have an Update Command Query Set? Also remove
BindingSource1.ResetBindings(False)

Does your ACCESS table have a Primary Key?

Ok the Select Case was a demo so you could create your queries by which checkbox was checked. You really need to study up on your ADO.Net. I'm not trying to be condescending but the questions your asking tell me you need to do a little research on SQL Server operations with VB.Net. Click Here

You create a command, connection, dataadapter, and datatable or dataset. Then you use the data in the datatable to populate your controls. For the Listbox you need the following query "Select Last_First_Name From [tablename];" that's your Command's Text. You would populate the ListBox using a SqlDataReader
Click Here

If your CSV File has headers you can Just get the columns you want by the SELECT Query.

 Dim objCmdSelect As New OleDbCommand("SELECT Col1,Col2,col3... FROM " & fi.Name, objConn)

Your query for the selected person from the ListBox should be like
SELECT Field1, Field2, Field3... FROM [TableName] WHERE Last_First_Name = 'selectedName';

Use the following to create your queries based on the CheckBoxes Checked State

        Select Case True
            Case CheckBox1.Checked And CheckBox2.Checked
                MsgBox("Both CheckBoxes Are Checked")
            Case CheckBox1.Checked
                MsgBox("CheckBox 1 Checked")
            Case CheckBox2.Checked
                MsgBox("CheckBox 2 Checked")
            Case Else
                MsgBox("No Checkbox Is Checked")
        End Select

I haven't had a chance to test this but I'm pretty sure you can ->Instead of deleting your record from the datatable. Me.TransmissoesDataSet.Tables("utilizador_Avancado").Rows(itemFound).Delete()

Remove the item from the BindingSource and call ResetBindings(False) Method.

 bs.RemoveAt(itemFound)
 bs.ResetBindings(False)

Then Accept changes method on the table. You should be able to use the Adapter Update then.

Very True Minimalist I just tested my code and it didn't matter they just have to be distinct

Yes I understand that it returns the matching elements. I went to the MSDN and read that it only returns Distinct elements that match so that is probably why the one l is all I got back. Also, I didn't realize they had to be in the same position(index) of the collection.

I guess I will have to find some other method to get all the matching elements whether or not they're Distinct. I was hoping that was my answer as it's not a lot of coding but what would be the fun!!!!

You will need to decide which fields you'll be needing from your sql server datatable. then you can create the commands, connection, dataadapter, and dataset.Then you can use the field with the names for your ListBox.

Here is a MSN page on how to fill your dataset.
Click Here

SQL Server Connection Strings Click Here

Once you get that going, let me know, then we can move on to the selecting records by the selected name.

I have a question about the string.intersect method.

I am not getting the results I expect.

        Dim lstChars1() As Char = "hello dolly" 'TextBox1.Text.ToCharArray
        Dim lstchars2() As Char = "help melanie" 'TextBox2.Text.ToCharArray

        Dim lst1 As New List(Of String)
        Dim lst2 As New List(Of String)

        For Each c In lstChars1
            lst1.Add(c.ToString)
        Next

        For Each c In lstchars2
            lst2.Add(c)
        Next

        Dim lstNew As IEnumerable(Of String) = Nothing
        lstNew = lst1.Intersect(lst2, StringComparer.OrdinalIgnoreCase)

lstNew contains "h", "e", "l", " "
I expected another 'l", What's the reason for this behavior? I have also attempted this using arrays and received the same values.

Thanks In Advance

What exactly are you trying to do? You have an array of Button then you give a variable btnName a type Button without using it. Then you take your button in the array and try to create a new button without the array index. Not sure what event handler you are using either I suppose it's the click events for both buttons you have in the array.

Anyway I believe your problem is the array is not being loaded when the form is opened. i ran your code and added the buttons to the array in the load event. Not sure why your looping thru the array and setting the value of toothName it will always be your second button name

    Dim btns(1) As Button
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Try
            btns(0) = Me.Button1
            btns(1) = Me.Button2
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub

    Private Sub Button_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click
        'Dim btnName As Button = DirectCast(sender, Button)
        Dim i As Integer
        'btns(i) = New Button
        Dim toothName As String = ""

        Try
            For i = 0 To btns.Length - 1
                toothName = " " & btns(i).Text & " - Upper " '<- in here it says Object reference not set to an instance of an object
            Next
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

    End Sub

That will stop your Object Reference Not Set Error and maybe you can go on from there

I was a little too hasty with my previous post it should have been:

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim lstChars1() As Char = TextBox1.Text.ToCharArray
        Dim lstchars2() As Char = TextBox2.Text.ToCharArray
        Dim ch As IEnumerable(Of Char) = lstChars1.Intersect(lstchars2)

        Dim out As String = String.Join(",", ch)

        MsgBox("There are " & ch.Count & " matching characters" & vbCrLf & out)
    End Sub

I would load the listbox with the names and when the user clicks the name you could execute a query against either the database or a DataSet to get your data about the person.

I'm not much into the binding of controls because mine usually fail when I need to do some workarounds which inevitably happens. So I all my coding of database to controls by hand. I've always hated the way Visual Studio stores the connectionString and all the DataSource operations. That's only my opinion and I know a lot of coders on here and elsewhere will frown on that but that's just me.

Anyway You could use LINQ against your datatable to retrieve the data you want about the selected person and display it in Textboxes or in Lables or even in a multiline textbox using some formating.

ignnniter, see if this helps you get your head around it.
I have a button and two textboxes on a form use the default names in the click event put this.

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim lstChars1() As Char = TextBox1.Text.ToCharArray
        Dim lstchars2() As Char = TextBox2.Text.ToCharArray
        Dim ch As IEnumerable(Of Char) = lstChars1.Intersect(lstchars2)

        Dim sb As New System.Text.StringBuilder
        For Each c In ch
            sb.Append(c & ", ")
        Next
        sb.Remove(sb.Length - 2, 2)

        MsgBox("There are " & ch.Count & " matching characters" & vbCrLf & sb.ToString)
    End Sub

First what are the 2 datasources? it looked from your first images of the data it was all in one table: Second what is supposed to happen when you click on a name in your listbox?

Start4me;
Sorry for the delay in replying...
I would have either have a textbox for each type of phone or some checkboxes or radiobuttons to determine which phone you'd want to query.

Probably shouldn't help dredge up this post but it was never actually answered in VB so here goes. Intellisense will give you 10 choices of how you want to Align your header text. VS2008 / 2012

DataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter

The following code shows how to put a table and some other minor things into a word doc. It's part of a database schema app. displaying the table name column names and their datatype ordinal position and if nullable. So the dbname and the table name are not important just strings. the datatable has to have data with column names. You will also need a reference to Microsoft.Office.Interop.Word

Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Word

Public Class WordDoc

    ''' <summary>
    ''' dTbl - The table you wish to display
    ''' tblName - Name of the Table 
    ''' dbName - the database File Path and Name
    ''' </summary>
    ''' <param name="dTbl"></param>
    ''' <param name="tblName"></param>
    ''' <param name="dbName"></param>
    ''' <remarks></remarks>
    Public Sub New(ByVal dTbl As DataTable, ByVal tblName As String, ByVal dbName As String)

        Dim oApp As Word.Application
        Dim oDoc As Word.Document
        Dim oPara1 As Word.Paragraph
        Try
            'Start a new document in Word                    
            oApp = CType(CreateObject("Word.Application"), Word.Application)

            oDoc = oApp.Documents.Add()

            Dim rws As Integer = dTbl.Rows.Count
            Dim cols As Integer = dTbl.Columns.Count

            ' Clear out any existing information.
            oDoc.Range.Delete()

            oPara1 = oDoc.Content.Paragraphs.Add
            oPara1.Range.MoveStart()
            oPara1.Range.Text = tblName & " TABLE"
            oPara1.Range.Font.Size = 10
            oPara1.Range.Font.Bold = CInt(True)
            oPara1.Format.SpaceAfter = 4
            oPara1.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft

            oPara1.Range.InsertParagraphAfter()

            Dim tlb As Word.Table
            tlb = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, CInt(rws + 1), CInt(cols))

            oApp.Visible = True
            tlb.Style = "Table Grid 8" '"wdTableFormatGrid8"  '"Table Grid 7" "Table Columns 5"

                'Data Rows 
            For j As Integer = 0 To CInt(rws) 'no -1 here as the headers need to be added

                If j = 0 Then
                    For i ...

If your problem is solved you should mark it as such.

Can you show some code where your error is happening. From the message it would seem you are trying to execute a query with the connection Closed.

Why not bind the datagridview to a bindingsource. the reset the bindingsource.
You will need a datatable or a collection but that should give you what you want. All you have to do is clear the datasource of the bindingsource and call the ResetBindings(False) method on the bindingsource

Quick and dirty demo

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim filePathAndName As String = SelectFile()

        If filePathAndName IsNot Nothing Then
            Dim dir As String = GetFolder()
            If dir IsNot Nothing Then
                My.Computer.FileSystem.CopyFile(filePathAndName, dir & "\" & _
                                                System.IO.Path.GetFileName(filePathAndName), True)
            End If
        End If
    End Sub

    Private Function GetFolder() As String

        Dim fldr As String = Nothing

        With fbd1
            .Description = "SELECT DIRECTORY FOR EXCEL FILE"
            .ShowNewFolderButton = True
            Dim dlgResult As DialogResult = .ShowDialog()
            If dlgResult = Windows.Forms.DialogResult.OK Then
                fldr = .SelectedPath
            Else
                MsgBox("EXCEL FILE WASN'T SAVED")
                fldr = Nothing
                Return fldr
                Exit Function
            End If

        End With

        Return fldr

    End Function

    Private Function SelectFile() As String
        Dim file As String = Nothing

        With ofd1
            .InitialDirectory = "c:\"
            .Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
            .Multiselect = False
            .RestoreDirectory = True
            If .ShowDialog = DialogResult.OK Then
                file = .FileName
            End If
        End With

        Return file

    End Function

End Class

You didn't provide the name for the file in the destination

My.Computer.FileSystem.CopyFile("C:\Users\coder\Desktop\EXCEL PROJECT\excel\1_2012.xlsx", My.Computer.FileSystem.SpecialDirectories.Desktop & "\TestCopy.xlsx", True)

Click Here

Try the following in your code. If it doesn't work take the single quotes from around searchStr it is probably Type integer in the Database Table

Dim cmd As New OleDbCommand

        Dim da As OleDbDataAdapter
        With cmd
            .CommandText = "select * from car where Renter_ID = '" & searchStr & "'"
            .CommandType = CommandType.Text
            .Connection = conn
        End With
        da = New OleDbDataAdapter()
        With da
            .SelectCommand = cmd
            .Fill(dt)
            .Dispose()
        End With

Why not look for the LastIndexOf("0")

Click Here