Click here to Skip to main content
15,897,291 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Iterate through Array Pin
Guffa9-Feb-07 7:39
Guffa9-Feb-07 7:39 
GeneralRe: Iterate through Array Pin
Larry White9-Feb-07 8:35
Larry White9-Feb-07 8:35 
AnswerRe: Iterate through Array Pin
Guffa10-Feb-07 3:57
Guffa10-Feb-07 3:57 
GeneralRe: Iterate through Array Pin
Larry White12-Feb-07 4:33
Larry White12-Feb-07 4:33 
AnswerRe: Iterate through Array Pin
Guffa12-Feb-07 4:57
Guffa12-Feb-07 4:57 
GeneralRe: Iterate through Array Pin
Larry White12-Feb-07 5:21
Larry White12-Feb-07 5:21 
AnswerRe: Iterate through Array Pin
Guffa13-Feb-07 11:34
Guffa13-Feb-07 11:34 
GeneralRe: Iterate through Array Pin
Larry White15-Feb-07 4:29
Larry White15-Feb-07 4:29 
Thank you for your suggestions. I rearranged most of my variables to be local. I have another issue you may be able to help me on. I'm using the following code to perform a SQL SELECT to combine the first & last name, and the employee ID number to be used in a listbox. The user selects multiple names that are transfered to a textbox. When they are selected, the array is created, which is used to create a record in a SQL table (one entry per name). The problem I have is, I need to update the Employee ID field but haven't found the right code to extract the "emplid" data. The name field works fine.

Dim sql1 As String = "Select (LastName + ', ' + FirstName) As Name, emplid FROM Users ORDER BY LastName"

Dim strCommandText As String = "INSERT INTO Orders(OrderDate, DeliverDate, DeliverLocation, Name, Special, Comments, Rate, EMPLID, LoggedIP)" & "VALUES('" & strOrderDate & "','" & strDeliverDate & "','" & strDeliverLocation & "','" & strName & "','" & strSpecial & "'" & ",'" & strComments & "','" & strRate & "','" & strEMPLID & "','" & strLoggedHost & "')"

Private Sub lbName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbName.SelectedIndexChanged
        Dim i As Integer
        editName.Text = Nothing
        For i = 0 To lbName.SelectedItems.Count - 1
            arrList2.Add(lbName.SelectedItems(i))
            With arrList2
                .ToArray()
            End With
            editName.Text = editName.Text & lbName.SelectedItems(i) & vbCrLf
        Next
        i = Nothing
    End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

        Dim i As Integer
        Dim r As String
        Dim x As String

        editComments.Clear()
        strComments = editComments.Text

        Try
            SqlConnection1.Close()
            cnn1.Close()
            SqlConnection1.Open()

            ' Create a name array from editName textbox; Used to create a new record for each name

            For i = 0 To arrList2.Count - 1
                strName = arrList2.Item(i)
                x = arrList2.Item(i)

                Dim strCommandText As String = "INSERT INTO Orders(OrderDate, DeliverDate, DeliverLocation, Name, Special, Comments, Rate, EMPLID, LoggedIP)" & "VALUES('" & strOrderDate & "','" & strDeliverDate & "','" & strDeliverLocation & "','" & strName & "','" & strSpecial & "'" & ",'" & strComments & "','" & strRate & "','" & strEMPLID & "','" & strLoggedHost & "')"

                Dim cmd As New SqlClient.SqlCommand(strCommandText, SqlConnection1)
                cmd.ExecuteNonQuery()
            Next
        Catch eEndEdit As System.Exception
            System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
        Finally
            If strRate = strRateBreakfast Then
                MessageBox.Show("Galley orders for BREAKFAST on: " & Now() & " have been successfully entered!", MessageBoxIcon.Information)
            ElseIf strRate = strRateDinner Then
                MessageBox.Show("Galley orders for DINNER on: " & Now() & " have been successfully entered!", MessageBoxIcon.Information)
            End If
            SqlConnection1.Close()
            cmd = Nothing
        End Try
        Close()
    End Sub


LWhite

QuestionXML Serialisation Pin
Sebastian T Xavier9-Feb-07 6:45
Sebastian T Xavier9-Feb-07 6:45 
AnswerRe: XML Serialisation Pin
TwoFaced9-Feb-07 17:26
TwoFaced9-Feb-07 17:26 
GeneralRe: XML Serialisation Pin
Sebastian T Xavier11-Feb-07 23:26
Sebastian T Xavier11-Feb-07 23:26 
Questionopen sound file button Pin
comicsuperfan19-Feb-07 5:26
comicsuperfan19-Feb-07 5:26 
QuestionReconnaître un répertoire en lecture seul Pin
prady929-Feb-07 4:23
prady929-Feb-07 4:23 
AnswerRe: Reconnaître un répertoire en lecture seul Pin
Dave Kreskowiak9-Feb-07 5:24
mveDave Kreskowiak9-Feb-07 5:24 
AnswerRe: Reconnaître un répertoire en lecture seul Pin
Garth J Lancaster9-Feb-07 13:29
professionalGarth J Lancaster9-Feb-07 13:29 
QuestionData Report of vb 6 Not refresh help required Pin
amjad ali shah9-Feb-07 3:06
amjad ali shah9-Feb-07 3:06 
Questionclass library Pin
dalbhide bipin9-Feb-07 1:35
dalbhide bipin9-Feb-07 1:35 
AnswerRe: class library Pin
Bassam Saoud9-Feb-07 2:42
Bassam Saoud9-Feb-07 2:42 
QuestionHow to get combobox value in a textbox Pin
rrrriiizz9-Feb-07 0:31
rrrriiizz9-Feb-07 0:31 
AnswerRe: How to get combobox value in a textbox Pin
amjad ali shah9-Feb-07 1:05
amjad ali shah9-Feb-07 1:05 
GeneralRe: How to get combobox value in a textbox Pin
rrrriiizz9-Feb-07 17:32
rrrriiizz9-Feb-07 17:32 
GeneralRe: How to get combobox value in a textbox [modified] Pin
The ANZAC9-Feb-07 19:05
The ANZAC9-Feb-07 19:05 
GeneralRe: How to get combobox value in a textbox Pin
amjad ali shah9-Feb-07 19:17
amjad ali shah9-Feb-07 19:17 
GeneralRe: How to get combobox value in a textbox Pin
TwoFaced9-Feb-07 21:22
TwoFaced9-Feb-07 21:22 
GeneralRe: How to get combobox value in a textbox Pin
rrrriiizz12-Feb-07 21:35
rrrriiizz12-Feb-07 21:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.