oussama_1 39 Posting Whiz in Training

Means Cell 9 does not exist
here's a code i wrote it'll simplify your work (less codes :D)

        For i = 1 To DataGridView1.Columns.Count - 1
            Dim label As Label = CType(Me.Controls("label" & i + 1), Label)
            If Not DataGridView1.CurrentRow.Cells(i).ToString = "" Or Nothing Then
                label.Text = DataGridView1.CurrentRow.Cells(i).Value
            End If
        Next
oussama_1 39 Posting Whiz in Training

Mark Question Solved please

oussama_1 39 Posting Whiz in Training
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source='" & "C:\Users\User\Desktop\Database3.accdb" & "';" & "Persist Security Info=False;" & "Jet OLEDB:Database Password=" & ";")
        Dim date1 As New TextBox
        Dim time1 As New TextBox
        Dim s1 As New TextBox
        Dim s2 As New TextBox
        Dim Empid As New TextBox
        Dim InOut As New TextBox
        Dim textfile As New RichTextBox
        Dim progress As New ProgressBar
        Me.Controls.Add(progress)
        'fill these out
        'progress.Location = New Point( , )
        'progress.Size = New Size ( , )


        textfile.LoadFile("C:\Users\User\Desktop\New Text Document.txt", RichTextBoxStreamType.PlainText)

        progress.Maximum = textfile.Lines.Count - 1

        For Each line In textfile.Lines
            If line = "" Or Nothing Then
            Else
                line = line.Replace(" ", "\").Replace("\\\\", "\").Replace("\\\", "\").Replace("\\", "\")
                ' now you have a (\) between each item instead of spaces
                date1.Text = line.Substring(0, line.IndexOf("\"))
                Dim a As String = Replace(line, date1.Text & "\", "", 1, 1)
                line = a
                time1.Text = line.Substring(0, line.IndexOf("\"))
                Dim b As String = Replace(line, time1.Text & "\", "", 1, 1)
                line = b
                s1.Text = line.Substring(0, line.IndexOf("\"))
                Dim c As String = Replace(line, s1.Text & "\", "", 1, 1)
                line = c
                s2.Text = line.Substring(0, line.IndexOf("\"))
                Dim d As String = Replace(line, s2.Text & "\", "", 1, 1)
                line = d
                Empid.Text = line.Substring(0, line.IndexOf("\"))
                Dim f As String = Replace(line, Empid.Text & "\", "", 1, 1)
                line = f
                InOut.Text = line.Substring(0, line.Length).Replace("\", "")
                Dim g As String = Replace(line, InOut.Text, "", 1, 1)
                line = g.Replace("\", …
oussama_1 39 Posting Whiz in Training

my code works!
this was the problem
e258ebbdad9a9d57b3519e4c7d368863
my access file needed some query fixes
thanks PerplexedB for your time

oussama_1 39 Posting Whiz in Training

meshe l 7al

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source='" & "YOURPATH\access.accdb" & "';" & "Persist Security Info=False;" & "Jet OLEDB:Database Password=" & ";")

        Dim date1 As New TextBox
        Dim time1 As New TextBox
        Dim s1 As New TextBox
        Dim s2 As New TextBox
        Dim Empid As New TextBox
        Dim InOut As New TextBox
        Dim textfile As New RichTextBox

        textfile.LoadFile("TEXT FILE PATH .txt", RichTextBoxStreamType.PlainText)

        For Each line In textfile.Lines
            If line = "" Or Nothing Then
            Else
                line = line.Replace(" ", "\").Replace("\\\\", "\").Replace("\\\", "\").Replace("\\", "\")
                ' now you have a (\) between each item instead of spaces
                date1.Text = line.Substring(0, line.IndexOf("\"))
                Dim a As String = Replace(line, date1.Text & "\", "", 1, 1)
                line = a
                time1.Text = line.Substring(0, line.IndexOf("\"))
                Dim b As String = Replace(line, time1.Text & "\", "", 1, 1)
                line = b
                s1.Text = line.Substring(0, line.IndexOf("\"))
                Dim c As String = Replace(line, s1.Text & "\", "", 1, 1)
                line = c
                s2.Text = line.Substring(0, line.IndexOf("\"))
                Dim d As String = Replace(line, s2.Text & "\", "", 1, 1)
                line = d
                Empid.Text = line.Substring(0, line.IndexOf("\"))
                Dim f As String = Replace(line, Empid.Text & "\", "", 1, 1)
                line = f
                InOut.Text = line.Substring(0, line.Length).Replace("\", "")
                Dim g As String = Replace(line, InOut.Text, "", 1, 1)
                line = g.Replace("\", "")


                Dim insertCommands As New OleDb.OleDbCommand("INSERT INTO import ([Date], [Time], [S1], [s2], [Empid], [in\out]) VALUES ('" & date1.Text & "','" & time1.Text & …
oussama_1 39 Posting Whiz in Training

Project - add reference - com - Microsoft access 12.0 object library

Code :

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source='" & "YOURPATH\access.accdb" & "';" & "Persist Security Info=False;" & "Jet OLEDB:Database Password=" & ";")

        Dim date1 As New TextBox
        Dim time1 As New TextBox
        Dim s1 As New TextBox
        Dim s2 As New TextBox
        Dim Empid As New TextBox
        Dim InOut As New TextBox
        Dim textfile As New RichTextBox

        textfile.LoadFile("YOUR TEXT FILE PATH.txt", RichTextBoxStreamType.PlainText)

        For Each line In textfile.Lines
            line = line.Replace(" ", "\").Replace("\\\\", "\").Replace("\\\", "\").Replace("\\", "\")
            ' now you have a (\) between each item instead of spaces
            date1.Text = line.Substring(0, line.IndexOf("\"))
            line = line.Replace(date1.Text & "\", "")
            time1.Text = line.Substring(0, line.IndexOf("\"))
            line = line.Replace(time1.Text & "\", "")
            s1.Text = line.Substring(0, line.IndexOf("\"))
            line = line.Replace(s1.Text & "\", "")
            s2.Text = line.Substring(0, line.IndexOf("\"))
            line = line.Replace(s2.Text & "\", "")
            Empid.Text = line.Substring(0, line.IndexOf("\"))
            line = line.Replace(Empid.Text & "\", "")
            InOut.Text = line.Substring(0, line.Length).Replace("\", "")
            line = line.Replace(InOut.Text, "")

            Dim insertCommands As New OleDb.OleDbCommand("INSERT INTO import ([Date], [Time], [S1], [s2], [Empid], [in\out]) VALUES ('" & date1.Text & "','" & time1.Text & "','" & s1.Text & "','" & s2.Text & "','" & Empid.Text & "','" & InOut.Text & "')", Connection)
            Try
                Connection.Open()
                insertCommands.ExecuteNonQuery()
            Catch ex As Exception
                MessageBox.Show(ex.Message & " - " & ex.Source)
            Finally
                Connection.Close()

            End Try

        Next

        MsgBox("Done")

    End Sub
End Class

Proof :

fff9ce1b2d0f609b30c12b84d6d84e1f

elie iza …

oussama_1 39 Posting Whiz in Training

hi, your code works perfectly
-check your typing
-account exist
-correct password
-gmail account

oussama_1 39 Posting Whiz in Training
Public Class Form1
    Dim dgv As New DataGridView
    Dim txt1 As New TextBox
    Dim txt2 As New TextBox
    Dim label1 As New Label
    Dim label2 As New Label
    Dim add As New Button
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Size = New Size(563, 224)
        Me.Controls.Add(dgv)
        Me.Controls.Add(txt1)
        Me.Controls.Add(txt2)
        Me.Controls.Add(label1)
        Me.Controls.Add(label2)
        Me.Controls.Add(add)
        label1.Text = "Values 1"
        label2.Text = "Values 2"
        label1.Location = New Point(4, 105)
        label2.Location = New Point(4, 131)
        txt1.Location = New Point(57, 102)
        txt2.Location = New Point(57, 128)
        add.Location = New Point(57, 154)
        add.Text = "Add"
        txt1.Text = "0"
        txt2.Text = "0"
        dgv.Size = New Size(547, 92)
        dgv.Columns.Add("Vendas1", "Vendas1")
        dgv.Rows.Add("0")
        dgv.Rows.Add("0")
        AddHandler add.Click, AddressOf addvalues
    End Sub

    Private Sub addvalues(ByVal sender As System.Object, ByVal e As System.EventArgs)
        dgv.Columns.Add("Vendas" & dgv.Columns.Count.ToString + 1, "Vendas" & dgv.Columns.Count.ToString + 1)
        dgv.Rows(0).Cells("Vendas" & dgv.Columns.Count.ToString).Value = txt1.Text
        dgv.Rows(1).Cells("Vendas" & dgv.Columns.Count.ToString).Value = txt2.Text
    End Sub
End Class
oussama_1 39 Posting Whiz in Training

won't work, use datatable instead of binding
sorry i'm busy right now, if you want the code let me know
good luck

oussama_1 39 Posting Whiz in Training

change the reading of your modem
SerialPort1.Encoding = Encoding.ASCII

oussama_1 39 Posting Whiz in Training

Mark Question Solved Please

oussama_1 39 Posting Whiz in Training
        Dim con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Resumen Guia\Base.mdb")
        Dim dataadapter1 As New System.Data.OleDb.OleDbDataAdapter()
        dataadapter1 = New System.Data.OleDb.OleDbDataAdapter("select * from Tabla ", con)
        Dim DtSet As System.Data.DataSet
        DtSet = New System.Data.DataSet
        dataadapter1.Fill(DtSet)
        ComboBox1.DataSource = Nothing
        ComboBox1.DataSource = DtSet.Tables(0)
        con.Close()
oussama_1 39 Posting Whiz in Training

hi, i need to see your code for adding objects (add button)

oussama_1 39 Posting Whiz in Training

so we did the same thing but it only worked for you :(
ill check my access file in dropbox tomorrow
10x PerplexedB

oussama_1 39 Posting Whiz in Training

Code :

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        Dim b1 As New pessoa()
        listaBindingSource.Add(b1)
        dgv.DataSource = listaBindingSource
        For i = 0 To dgv.Rows.Count - 1
            Dim num As Integer = i + 1
            dgv.Rows.Item(i).HeaderCell.Value = "Values" & num
        Next
    End Sub
End Class

Result :

1cdc994948106ce26d79b9f8ec2a9fa7

oussama_1 39 Posting Whiz in Training

just copying the code won't cut it, check your first application references.
or try to add microsoft.sqlserver reference
good luck

oussama_1 39 Posting Whiz in Training
       dgv.DataSource = listaBindingSource
        dgv.Columns(0).HeaderText = "Value"
        dgv.Columns(1).HeaderText = "Date"
        For i = 0 To dgv.Rows.Count - 1
            Dim num As Integer = i + 1
            dgv.Rows.Item(i).HeaderCell.Value = "Vendas" & num
        Next
oussama_1 39 Posting Whiz in Training

for your application to work on both operating system (32bit and 64bit) choose X86 platform
Build - Configuration Manager - Active Solution platform - new - new platform select X86

oussama_1 39 Posting Whiz in Training

Anybody ? :(

oussama_1 39 Posting Whiz in Training

i'm assuming the picture is inside the panel

    Private Sub Form_MouseWheel(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        _scaleDelta = Math.Sqrt(PictureBox1.Width * PictureBox1.Height) * 0.00005
        If e.Delta < 0 Then
            PictureBox1.Size = New Size(PictureBox1.Size.Width - 10, PictureBox1.Size.Height - 10)

        ElseIf e.Delta > 0 Then
            PictureBox1.Size = New Size(PictureBox1.Size.Width + 10, PictureBox1.Size.Height + 10)
            Dim mousep As Point = e.Location
            Dim panelcenter_w As String = Panel1.Size.Width / 2
            Dim panelcenter_h As String = Panel1.Size.Height / 2
            If mousep.X < panelcenter_w Then
                Dim centringx As String = panelcenter_w - (mousep.X)
                centringx = centringx / 12
                PictureBox1.Location = New Point(PictureBox1.Location.X + centringx, PictureBox1.Location.Y)
            Else
                Dim centringx As String = (mousep.X) - panelcenter_w
                centringx = centringx / 12
                PictureBox1.Location = New Point(PictureBox1.Location.X - centringx, PictureBox1.Location.Y)
            End If
            If mousep.Y < panelcenter_h Then
                Dim centringy As String = panelcenter_h - (mousep.Y)
                centringy = centringy / 12
                PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y + centringy)
            Else
                Dim centringy As String = (mousep.Y) - panelcenter_h
                centringy = centringy / 12
                PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y - centringy)
            End If
        End If
    End Sub
oussama_1 39 Posting Whiz in Training

Manually :

Toolbox
drag drop a listview into your form design
set listview view to details
Edit Columns

Programmatically :

        Me.Size = New Size(700, 300)
        Dim list As New ListView
        list.Size = New Size(684, 262)
        list.View = View.Details
        list.Columns.Add("File Directory")
        list.Columns.Add("name")
        list.Columns.Add("email")
        list.Columns.Add(" ip address")
        Me.Controls.Add(list)
oussama_1 39 Posting Whiz in Training

try this
Open ss.txt >> File >> Save as >> set Encoding to Unicode and replace file

oussama_1 39 Posting Whiz in Training
Public Class Form1
    Dim Seconds As String
    Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CloseButton.MouseDown
        Seconds = 0
        CloseLongTimer.Interval = 1000
        CloseLongTimer.Start()
    End Sub
    Private Sub CloseLongTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles CloseLongTimer.Tick
        Seconds += 1
    End Sub
    Private Sub CloseButton_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CloseButton.MouseUp
        CloseLongTimer.Stop()
        If Seconds < 5 Then
            Me.Close()
        Else
            System.Environment.Exit(1)
        End If
    End Sub
End Class
oussama_1 39 Posting Whiz in Training

there is 9 check it

46582810686b4ace191eb27255d50758

oussama_1 39 Posting Whiz in Training

wont work :(
you have the file so please try this code :

     Dim Connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source='" & yourlocation\InvoiceProgram.accdb & "';" & "Persist Security Info=False;" & "Jet OLEDB:Database Password=" & ";")
     ' the record already exist in customers with the ID 9
    Dim IDnum As String = "9"
    Dim insertCommands As New OleDb.OleDbCommand("INSERT INTO Orders (OrdersID) VALUES (" & IDnum & ")", Connection)
    Try
    Connection.Open()
    insertCommands.ExecuteNonQuery()
    Catch ex As Exception
    MessageBox.Show(ex.Message & " - " & ex.Source)
    Finally
    Connection.Close()
    End Try

and tell me why it wont work
thank you

oussama_1 39 Posting Whiz in Training
    Private Sub Form_MouseWheel(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
        _scaleDelta = Math.Sqrt(PictureBox1.Width * PictureBox1.Height) * 0.00005
        If e.Delta < 0 Then
            PictureBox1.Size = New Size(PictureBox1.Size.Width - 10, PictureBox1.Size.Height - 10)
        ElseIf e.Delta > 0 Then
            PictureBox1.Size = New Size(PictureBox1.Size.Width + 10, PictureBox1.Size.Height + 10)
        End If
    End Sub
oussama_1 39 Posting Whiz in Training

sure and thanks a lot

oussama_1 39 Posting Whiz in Training

ok Here's the access file
Dropbox.com
user oussama.j.zeidan@gmail.com
pass 123456

oussama_1 39 Posting Whiz in Training

yes you are right about the relation but none of the codes works for me.
say there's a customer with ID = 1 and i would try the code above or any of the codes to insert the number 1 into ordersID still wont work
i think it got something to do with the fact its a combobox am i right ?
thank for your help

oussama_1 39 Posting Whiz in Training

Sorry i forgot to mention that OrdersID Column is a Combobox
9861f07c51a4ce405502437cab294106

oussama_1 39 Posting Whiz in Training

i tried these statements :

"INSERT INTO Orders (OrdersID) VALUES ('" & IDnum & "')"



"INSERT INTO Orders (OrdersID) VALUES (" & IDnum & ")"




"INSERT INTO Orders ([OrdersID]) VALUES ('" & IDnum & "')"



"INSERT INTO Orders VALUES ('" & IDnum & "')"



"INSERT INTO Orders ([OrdersID]) VALUES (" & IDnum & ")"



Dim IDnum as Integer = 4
"INSERT INTO Orders (OrdersID) VALUES (" & IDnum & ")"

all with the same error message, Syntax error in INSERT INTO statement.

oussama_1 39 Posting Whiz in Training

Try this

'Read data according to CandidateReferenceNumber
Dim MyCommand As New System.Data.OleDb.OleDbDataAdapter()
' * = everything
if combobox1.selecteditem = "" or nothing then
msgbox("Enter CandidateReferenceNumber")
else
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from tblCandidates WHERE fldCandidateReferenceNumber = " & combobox1.selecteditem, Connection)
   Dim DtSet1 As System.Data.DataSet
        DtSet1 = New System.Data.DataSet
        MyCommand.Fill(DtSet1)
     'Candidate = your table in form
     Candidate.DataSource = DtSet.Tables(0)
        Connection.Close()
        end if

'########################################


'Delete Data
run.CommandType = CommandType.Text
run.CommandText = "DELETE FROM tblCandidates WHERE fldCandidateReferenceNumber = " & combobox1.selecteditem
 Using Connection
                Connection.Open()
                run.ExecuteNonQuery()
                Connection.Close()
            End Using


'for updating use INSERT INTO statement
oussama_1 39 Posting Whiz in Training
  1. sorry my bad (its not the problom though :D)
  2. no its not autonumber or primary key its just a number
  3. the number already exist in the first table according to the relation

these are not the problem.. im going crazy over this
4c32c86188ccaf954b57332654ff9fbc

cf7074b4bd528eb1456822fe6d4f0ef5

thank you PerplexedB

oussama_1 39 Posting Whiz in Training

Hi
I have access database with two tables With a Relationship i can insert records into the first table with no problems but when im trying to insert a record in the second table i got error message
Error message : Syntax error in INSERT INTO statement. - Microsoft Office Access Database
Second Table Name : Orders
Column Name of the second table : OrdersID
OrdersID Datatype : Numbers
Code :

  Dim Connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source='" & My.Settings.report & "';" & "Persist Security Info=False;" & "Jet OLEDB:Database Password=" & ";")
        Dim IDnum As String = "4"
        Dim insertCommands As New OleDb.OleDbCommand("INSERT INTO Orders (OrdersID) VALUES ('" & IDnum & "')", Connection)
        Try
            Connection.Open()
            insertCommanddss.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.Message & " - " & ex.Source)
        Finally
            Connection.Close()
        End Try

The Same Code Works perfectly on the First table
So Whats Wrong ?!
thanks