5 Replies - 533 Views - Last Post: 04 February 2016 - 05:25 AM Rate Topic: -----

#1 AverageJoe   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 30-March 15

-1 Output to Data Grid View after Input to database

Posted 02 February 2016 - 09:20 AM

I'm creating a simple system for my project management class, so the idea behind the course is to practice good project management skills, not at all focused on coding procedures. I created a simple 1 Table database in Access and followed a couple tutorials on how to attach this database to my program...

I'm receiving two errors:

1. When I input data into the database first, which obviously isn't ideal, the error message I get when running the program is "The data is either too long or too short for an int32 format" its referring to my phone number column which is set as "Long Text".

2. Whenever I leave the database blank to input data from the program the output to the data grid view is (-1)



 
Public Class Form3
    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Member1DataSet.Table1' table. You can move, or remove it, as needed.
        Table1TableAdapter.Fill(Me.Member1DataSet.Table1)
        DataGridView1.AllowUserToAddRows = False
    End Sub

    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        Table1BindingSource.AddNew()
        txtID.Text = ""
        txtFirstName.Text = ""
        txtLastName.Text = ""
        txtEmail.Text = ""
        txtCell.Text = ""
        txtHome.Text = ""
        txtAddress.Text = ""
        txtCity.Text = ""
        txtState.Text = ""
        txtZip.Text = ""
    End Sub
    Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
        Table1BindingSource.RemoveCurrent()
    End Sub
    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        On Error GoTo SaveErr
        Table1BindingSource.EndEdit()
        Table1TableAdapter.Update(Member1DataSet.Table1)
        MessageBox.Show("All information saved successfully!")
SaveErr:
        Exit Sub
    End Sub
    Private Sub btnPrevious_Click(sender As Object, e As EventArgs) Handles btnPrevious.Click
        Table1BindingSource.MovePrevious()
    End Sub

    Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
        Table1BindingSource.MoveNext()
    End Sub
End Class



Is This A Good Question/Topic? 0
  • +

Replies To: -1 Output to Data Grid View after Input to database

#2 DarenR   User is offline

  • D.I.C Lover

Reputation: 593
  • View blog
  • Posts: 3,823
  • Joined: 12-January 10

Re: -1 Output to Data Grid View after Input to database

Posted 02 February 2016 - 10:39 AM

somewhere where your adding query is -- it is setting your data to integer instead of string
Was This Post Helpful? 0
  • +
  • -

#3 AverageJoe   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 30-March 15

Re: -1 Output to Data Grid View after Input to database

Posted 02 February 2016 - 10:59 AM

View PostDarenR, on 02 February 2016 - 10:39 AM, said:

somewhere where your adding query is -- it is setting your data to integer instead of string


any idea of where I can start looking?
Was This Post Helpful? 0
  • +
  • -

#4 DarenR   User is offline

  • D.I.C Lover

Reputation: 593
  • View blog
  • Posts: 3,823
  • Joined: 12-January 10

Re: -1 Output to Data Grid View after Input to database

Posted 04 February 2016 - 05:00 AM

what database are you using?

long text is not a property of ms sql

if the database column is set to int you will not be able to pass in a text column without converting it to int
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • blow up my boots
  • member icon

Reputation: 6544
  • View blog
  • Posts: 26,532
  • Joined: 12-December 12

Re: -1 Output to Data Grid View after Input to database

Posted 04 February 2016 - 05:13 AM

The OP is using MS Access. Long Text is the equivalent of the earlier Memo field (but Short Text is more than sufficient for a phone number).
Was This Post Helpful? 0
  • +
  • -

#6 DarenR   User is offline

  • D.I.C Lover

Reputation: 593
  • View blog
  • Posts: 3,823
  • Joined: 12-January 10

Re: -1 Output to Data Grid View after Input to database

Posted 04 February 2016 - 05:25 AM

View Postandrewsw, on 04 February 2016 - 07:13 AM, said:

The OP is using MS Access.



didnt think people still used that pos
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1