Begginnerdev 256 Junior Poster

Example:

Dim Conn as New OledbConnection(ConStr)
con.Open()
Dim Save as New OledbCommand("INSERT INTO Client(Nom,Prenom,Adresse,Téléphone,date) VALUES(@p1,@p2,@p3,@p4,@p5)",Conn)

'Add parameters'

Save.ExecuteNonQuery()
Begginnerdev 256 Junior Poster

You will need to make use of the Microsoft Office Interopt libraries if you are wanting to manipulate a workbook that is not open.

Begginnerdev 256 Junior Poster

Access is a single user application, therefore; it is not possible.

You might want to look into SQL or MySQL as an alternitave if you are wanting multiple users.

Begginnerdev 256 Junior Poster

Yep, if you want to check all of the radio buttons at once (Only allowing one answer/click) you will want to do the follwing:

AddHandler RadioButton1.Click, AddressOf RBC
AddHandler RadioButton2.Click, AddressOf RBC
AddHandler RadioButton3.Click, AddressOf RBC
AddHandler RadioButton4.Click, AddressOf RBC

Then place the IF code in the RBC Sub, checking for which radio button was clicked.

To check which control sent the action, make use of the sender object.

Begginnerdev 256 Junior Poster

You will need to create the sub for the click and then add the handler on runtime.

Example:

AddHandler RadioButton1.Click, AddressOf RBC

Private Sub RBC(sender As Object, e As EventArgs)
    'Place code here
End Sub
Begginnerdev 256 Junior Poster

One alternative is to place an open file dialog in the project, then allow the user to navigate to the data base.

You will:

1) Place the dialog
2) Do some coding to prevent empty paths
3) Store the value from the dialog on the form.
4) Create a backup button that will execute the backup.

You can also ad a Folder Browser Dialog to the project, to allow the user to chose where the backup will be placed

Code example:

    Dim SourceDir As String
    Dim DestDir As String


    If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
        If OpenFileDialog1.FileName <> "" Then
            SourceDir = OpenFileDialog1.FileName
        End If
    End If

    If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
        If FolderBrowserDialog1.SelectedPath <> "" Then
            If IO.Directory.Exists(FolderBrowserDialog1.SelectedPath) Then
                DestDir = FolderBrowserDialog1.SelectedPath & "/" 'Must add the / to end.'
            End If
        End If
    End If
Begginnerdev 256 Junior Poster

Use the command to fill a data adapter, and port that into a data table.

Then cycle through the data table and pass those values in.

Example:

    Dim da As New SqlDataAdapter
    Dim ds As New Data.DataSet
    Dim dt As New Data.DataTable

    da.SelectCommand = MyCommand
    da.Fill(ds, "myitems")
    dt = ds.Tables("myitems")

    For i = 0 To dt.Rows.Count - 1
        message.Body &= vbCrLf & dt.Rows(i).ToString
    Next
Begginnerdev 256 Junior Poster

What you will need to do is:

1) Loop through the workbook, comparing and storing all values that reference that person.
2) Loop through those values, adding them to the message (body?)**

It may be easier to write the values to a text file and attach the text file to the message.

Begginnerdev 256 Junior Poster

It is possible to have security permissons denying writing to the root of a drive.

Also, are you getting the data from notepad or something of the sort?

Begginnerdev 256 Junior Poster

I have this feeling that Iamature is begging for homework.

As Mitja stated, he has posted the same question, re worded, at least twice.

He also PM'ed me, asking for me to code his project for him.

I don't mind helping, but doing the work for someone is a different story.

Give a man a fish, he will eat for a day. Teach a man to fish, he will eat for a lifetime.

Begginnerdev 256 Junior Poster

I have a class for RS232 still, but I don't think that will help you any. :P

EDIT

Or would it....

Does anyone know if RS232 API will work with USB?

They are both "serial" ports.

Begginnerdev 256 Junior Poster

I will do some research to see if I can find some other references for you.

Begginnerdev 256 Junior Poster

Here is a good reference I used when I did a small project with USB manipulation.

Begginnerdev 256 Junior Poster

So you had to use date?

Begginnerdev 256 Junior Poster

Sure, if you don't mind.

Begginnerdev 256 Junior Poster

What form border style are you using?

I know I have had some issues when desinging in Sizable and then changing it to Fixed3D ect..

Are these controls placed inside another? ie. Panel, Groupbox ect..

Begginnerdev 256 Junior Poster

Do you have any code in the form's resize event or any code anywhere that changes their location?

Also, is the screen resolution any different when debugging/release?

Begginnerdev 256 Junior Poster

Soon enough a mod wil come move it for you. Normally takes about 2/3 hours for one to see it.

Begginnerdev 256 Junior Poster

You have actually posted this in the wrong forumn.

There ASP.NET form can be found Here

Begginnerdev 256 Junior Poster

Sorry for the long reply.
I am trying to recreate your problem.

Begginnerdev 256 Junior Poster

Ok. Just remeber that for every control that contains other controls, you will need another For loop.

Begginnerdev 256 Junior Poster

You will want to subtract one from QuestHistroyArray length

You will always want to subtract 1 from an array.
The last item will be a terminator character, so you will want the n - 1 index.

Begginnerdev 256 Junior Poster

Np friend, anything else I can help you with?

Begginnerdev 256 Junior Poster

You could create a boolean check.

Example:

Dim canExecute As Boolean = False



'From the ComboBox's indexChanged event, do the following:'

 If ComboBox1.SelectedValue = "A" Then
    canExecute = True
 End If



'From the Button's click event, do the following:'
If canExecute = True Then
    'My Code Here'
End If

Is this what you are looking for?

Begginnerdev 256 Junior Poster

For one thing,

myDa.Fill(mydataset, "Old_info")

and

search_data_DataGridView.DataSource = mydataset.Tables("Old_inf0").DefaultView

Are refrencing two different tables.

You have a zero placed at the end of

search_data_DataGridView.DataSource = mydataset.Tables("Old_inf0").DefaultView

thines01 commented: Good catch +12
Begginnerdev 256 Junior Poster

Something like this:

  Dim conStr As String = "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"

    Dim con As New SqlConnection(conStr)
    Dim cmd As SqlCommand

    Try
        Dim myValue As String = "This is a test."

        con.Open()

        Dim sqls As String = "INSERT INTO table (column) VALUES ('" & myValue & "')"
        cmd = New SqlCommand(sqls, con)
        cmd.ExecuteNonQuery()

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
Begginnerdev 256 Junior Poster

You could write a sql statement to instert each one, then place it in a loop.

Example:

    Dim conStr As String = "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;"

    Dim con As New SqlConnection(conStr)
    Dim cmd As SqlCommand

    Try

        For i = 0 To ComboBox1.Items.Count

            con.Open()

            Dim sqls As String = "INSERT INTO table (column) VALUES ('" & ComboBox1.Items(i).ToString & "')"
            cmd = New SqlCommand(sqls, con)
            cmd.ExecuteNonQuery()

        Next


    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
Begginnerdev 256 Junior Poster

Seduction is her game.

Lying

Begginnerdev 256 Junior Poster

Gum Kazakastan Llama

Begginnerdev 256 Junior Poster

lag -> internet

Begginnerdev 256 Junior Poster

Because he owns a Ford Pinto

Why did the chicken cross the road?

Begginnerdev 256 Junior Poster

No problem friend, any other issues you have?

Begginnerdev 256 Junior Poster

Here is a tiny little recursive sub procedure I have written to do what you are needing it to do.

Public Sub PlusOne(int As Integer)
    If int <= 1000 Then
        ListBox1.Items.Add("HelloWorld")
        int += 1
        PlusOne(int)
    End If
End Sub

Just need to pass 1 in as int when you first call the sub, and change ListBox1 to Console.WriteLine.

Begginnerdev 256 Junior Poster

tornado -> jet

Begginnerdev 256 Junior Poster

There are a number of ways to do what thines is saying.

Are you parseing the data in line by line or the entire file?

Are you storing the data in a single string or in an array?

Begginnerdev 256 Junior Poster

For loops are actualy pretty easy to use.

Example:

For Each object In Collection

Next

For Each Control in Me.Controls
'Loops through every control on the form.'
Next



For i = 0 to Me.Controls.Count

Next

'Would be the same as coding'
for(i=0;i=Me.Controls.Count;i++)
{

}

Hope this helps.

Begginnerdev 256 Junior Poster

Example:

Dim sqls As String = "SELECT column1 FROM table WHERE primarykey=value"
Begginnerdev 256 Junior Poster

Example:

Dim sqls As String = "INSERT INTO table (column1) VALUE ('" & DateTimePicker1.Value & "')"
Begginnerdev 256 Junior Poster

It would work.

If you wanted to remove it later you could try:

t.RemoveAt(t.IndexOf(txtField4))
Begginnerdev 256 Junior Poster

Does anyone have anything else to add to the discussion?

If not, I will go ahead and close the thread.

Begginnerdev 256 Junior Poster

I forgot to add, to retrieve the object from the ArrayList, it's good practice to do the following.

Dim txtBox As TextBox = TryCast(t(i), TextBox)
Dim lbl As Label = TryCast(l(i),Label)

If the cast fails, they will return Nothing.

So by just checking to ensure they are not nothing, you will safeguard from null references.

Begginnerdev 256 Junior Poster

Here is a rewritten version of your code using ArrayLists (better when dynamicly adding/removing from a list/array)

Dim t As New ArrayList
Dim l As New ArrayList

   For i = 0 To intNoColumns - 1
        Dim lbl As New Label
        Dim txt As New TextBox

        lbl.Name = "lblField" & i
        lbl.Location = New Point(25, intylocation)
        lbl.Size = New Size(300, 15)
        lbl.Text = dt.Columns(i).ToString
        Me.pnlResults.Controls.Add(lbl)

        txt.Name = "txtField" & i
        txt.Location = New Point(150, intylocation)
        txt.Size = New Size(300, 10)
        txt.Text = dt.Rows(intCurrentRecord).Item(i)

        If lbl.Text = strPrimaryKey Then
            txt.Enabled = False
            intPrimaryKeyIndex = i
        End If
        Me.pnlResults.Controls.Add(txt)

        intylocation += 50

        t.Add(txt)
        l.Add(lbl)
    Next

This will be must easier for you to use than using redim for each new item in the array.

Begginnerdev 256 Junior Poster

You might also want to wrap your code in try/catch blocks.

Begginnerdev 256 Junior Poster

I think what thines is trying to say is you will have to post some code so we can look at it.

We can't exactly tell what's going wrong if we can't see your code. :)

Begginnerdev 256 Junior Poster

Your If statement is convlicting with what you are wanting.

You are checking to see if the row is not empty, and checking to see if string value is not empty.

Then removing it when it satisfies both conditions.

I think what you are looking for is:

If IsNothing(row.Cells(j).Value) = true AND row.Cells(j).Value.ToString = "" Then
    DataGridView1.Rows.RemoveAt(i)
End If

Also, from what I see, you are only removing the row at position 0.

Are you incrementing your index, i?

One more thing.

If you are wanting to cycle through the entire row, your code should look somthing like this:

    Dim i As Integer = 0
    Dim mtCell As Integer = 0
    For Each row As DataGridViewRow In DataGridView1.Rows
        For j = 0 To row.Cells.Count
            If IsNothing(row.Cells(j).Value) = True And row.Cells(j).Value.ToString = "" Then
                mtCell += 1
            End If
        Next

        If mtCell = row.Cells.Count Then
                DataGridView1.Rows.RemoveAt(i)
        End If


        i += 1
        mtCell = 0
    Next
Begginnerdev 256 Junior Poster

You will have to right a for/each loop for each sub level.

Each level is considered it's own collection.

Example:

For Each i As Control In Me.Controls
        For Each j As Control In i.Controls
            For Each k As Control In j.Controls
                If TypeOf k Is TextBox Then

                End If
            Next
            If TypeOf j Is TextBox Then

            End If
        Next
        If TypeOf i Is TextBox Then

        End If
    Next
Begginnerdev 256 Junior Poster

Here is another person who has asked a similar question.

Begginnerdev 256 Junior Poster

You will have to change your command strings.

Any STRING that is being entered into a command should be wrapped in `'s.

Example:

SELECT * FROM book WHERE isbn='" & Cstr(intISBN) & "'"

You just need to fix your queries.

adam_k commented: Agree +8
Begginnerdev 256 Junior Poster

I have used WinForms primarily, but have attempted a few small projects with WPF.

My biggest issue is the taxation on hardware. Not everyone has an up to date pc.

Heck, I still know people who are on Windows 98. D:

Begginnerdev 256 Junior Poster

I agree, I do not like that Microsoft is tossing winforms for WPF.

Seems to me like they are leaning more and more torward the "Metro Mindset".

I personally could care less what an app LOOKs like, it's about the programming and logic behind the app.

WPF just seems like it is getting more and more taxing on hardware.

Ofcourse, it looks good, but you pay for looks.

cough Apple cough