Click here to Skip to main content
15,900,405 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionvb.net Pin
rampraba15-Aug-07 23:27
rampraba15-Aug-07 23:27 
AnswerRe: vb.net Pin
Zia Ul Haq Soofi15-Aug-07 23:49
Zia Ul Haq Soofi15-Aug-07 23:49 
AnswerRe: vb.net Pin
Taylor Kobani15-Aug-07 23:55
Taylor Kobani15-Aug-07 23:55 
AnswerRe: vb.net Pin
Christian Graus15-Aug-07 23:56
protectorChristian Graus15-Aug-07 23:56 
QuestionPadding is invalid and cannot be removed. Pin
WhiteGirl2315-Aug-07 22:50
WhiteGirl2315-Aug-07 22:50 
AnswerRe: Padding is invalid and cannot be removed. Pin
Luc Pattyn15-Aug-07 23:58
sitebuilderLuc Pattyn15-Aug-07 23:58 
GeneralRe: Padding is invalid and cannot be removed. Pin
WhiteGirl2316-Aug-07 2:09
WhiteGirl2316-Aug-07 2:09 
QuestionError when add a record in the database Pin
Mekong River15-Aug-07 22:24
Mekong River15-Aug-07 22:24 
Hi all, I have a problem when i try to add a record into my database system. I have a database in Microsoft access and the table name is tblOrgInfo. This table contain three field:

OrgNo (AutoNumber)
OrgName (Text)
Address (Text)

The below is the code that I use vb 2005 to add the record into the database system:

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

        ' Check whether the user type in the name of an organization.
        ' If the user didn't type any name, the system won't allow
        ' the user to add organization information into the database system.
        If Trim(txtOrgName.Text) <> "" Then
            Dim cmdAddOrgName As New OleDbCommand
            With cmdAddOrgName
                .Connection = cnnDonorDb
                .CommandType = CommandType.Text
                .CommandText = "INSERT INTO tblOrgInfo (OrgName, Address) VALUES ('" & Trim(txtOrgName.Text) & "', '" & txtAddress.Text & "'")                Try
                    .Connection.Open()
                Catch exFileNotFound As System.Data.OleDb.OleDbException
                    MessageBox.Show("The system has a problem to connect to your database system." & ControlChars.CrLf & "Please verify that your database is located in the following path: 'C:\DICDonorDb\DICDornorDb.mdb'", "Database file not found", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Exit Sub
                End Try
                .ExecuteNonQuery()
                   .Connection.Close()
            End With
            ' Inform the user after succesffuly add an information into
            ' the database system.
            MessageBox.Show("'" & Trim(txtOrgName.Text) & "' organization is successfully add into the database system." & ControlChars.CrLf & "The systme will clear an information of this organization on the form in order to add new organization information.", "Successfully Add an Organization Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
            ' Clear an information on the form.
            txtOrgName.Text = ""
            txtAddress.Text = ""
            mtbPhone.Text = ""
            txtEmail.Text = ""
            txtAddress.Text = ""
            txtNote.Text = ""
        ElseIf Trim(txtOrgName.Text) = "" Then
            MessageBox.Show("You didn't write an organization name to record in the database system." & ControlChars.CrLf & "Please specified an organization name before adding an organization information into the database system.", "Missing Organization Name", MessageBoxButtons.OK, MessageBoxIcon.Stop)
            btnAdd.Focus()
        End If

    End Sub


The bold is the place that error occure. And the italic line (commandtext) is the place that I suspect that it cause the problem. In here, I didn't give the value of OrgNo field because I think it is an autonumber data type. So I just give the value to OrgName and Address.

Please suggestion for the solution.
Thank
Kanel
AnswerRe: Error when add a record in the database Pin
Christian Graus15-Aug-07 22:33
protectorChristian Graus15-Aug-07 22:33 
GeneralRe: Error when add a record in the database Pin
MartyK200715-Aug-07 22:56
MartyK200715-Aug-07 22:56 
GeneralRe: Error when add a record in the database Pin
Mekong River15-Aug-07 23:07
Mekong River15-Aug-07 23:07 
GeneralRe: Error when add a record in the database Pin
MartyK200715-Aug-07 23:09
MartyK200715-Aug-07 23:09 
GeneralRe: Error when add a record in the database Pin
Mekong River15-Aug-07 23:11
Mekong River15-Aug-07 23:11 
GeneralRe: Error when add a record in the database Pin
MartyK200715-Aug-07 23:22
MartyK200715-Aug-07 23:22 
GeneralRe: Error when add a record in the database Pin
Mekong River15-Aug-07 23:05
Mekong River15-Aug-07 23:05 
GeneralRe: Error when add a record in the database Pin
Christian Graus15-Aug-07 23:21
protectorChristian Graus15-Aug-07 23:21 
GeneralRe: Error when add a record in the database Pin
Tom Deketelaere15-Aug-07 23:24
professionalTom Deketelaere15-Aug-07 23:24 
GeneralRe: Error when add a record in the database Pin
Mekong River15-Aug-07 23:54
Mekong River15-Aug-07 23:54 
GeneralRe: Error when add a record in the database Pin
Christian Graus15-Aug-07 23:57
protectorChristian Graus15-Aug-07 23:57 
GeneralRe: Error when add a record in the database Pin
Mekong River16-Aug-07 0:01
Mekong River16-Aug-07 0:01 
GeneralRe: Error when add a record in the database Pin
Christian Graus16-Aug-07 0:11
protectorChristian Graus16-Aug-07 0:11 
GeneralRe: Error when add a record in the database Pin
Mekong River16-Aug-07 0:19
Mekong River16-Aug-07 0:19 
GeneralRe: Error when add a record in the database Pin
Tom Deketelaere16-Aug-07 0:32
professionalTom Deketelaere16-Aug-07 0:32 
GeneralRe: Error when add a record in the database Pin
Christian Graus16-Aug-07 11:50
protectorChristian Graus16-Aug-07 11:50 
AnswerRe: Error when add a record in the database Pin
Vimalsoft(Pty) Ltd16-Aug-07 22:20
professionalVimalsoft(Pty) Ltd16-Aug-07 22:20 

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.