Click here to Skip to main content
15,910,877 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhow to make a file password protected ????? Pin
San@Coding22-Aug-07 17:08
San@Coding22-Aug-07 17:08 
AnswerRe: how to make a file password protected ????? Pin
Dave Kreskowiak23-Aug-07 3:16
mveDave Kreskowiak23-Aug-07 3:16 
QuestionSystem.ExecutionEngineException Pin
dimuthuvbnet22-Aug-07 15:40
dimuthuvbnet22-Aug-07 15:40 
AnswerRe: System.ExecutionEngineException Pin
Michael Sync22-Aug-07 20:29
Michael Sync22-Aug-07 20:29 
AnswerRe: System.ExecutionEngineException Pin
Vimalsoft(Pty) Ltd22-Aug-07 21:12
professionalVimalsoft(Pty) Ltd22-Aug-07 21:12 
QuestionHow to Fast search data in XML ? Pin
nimolZero22-Aug-07 15:40
nimolZero22-Aug-07 15:40 
AnswerRe: How to Fast search data in XML ? Pin
Christian Graus22-Aug-07 15:49
protectorChristian Graus22-Aug-07 15:49 
QuestionErr when add record into database Pin
Mekong River22-Aug-07 15:13
Mekong River22-Aug-07 15:13 
Hi, currently I am developing a database application in vb2005 with ms access as a database back end. In my Ms access there is one table name tblProgBudget with the following field:

- ProgID (Number)<br />
- Year (Number)<br />
- ProgBudYear (AutoNumber)<br />
- GovContrib (Currentcy)<br />
- OrgContrib (Current)


I write a code in vb 2005 try to insert new record into this table (I add to all field except ProgBudYear because this field is autonumber field so I want the system to generate it by automatically). The below is my code:

Private Sub btnAddProg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddProg.Click

        ' Check whether the user select any organization name.
        If cboSelOrgName.Text <> "" Then
            ' Check whether the user select any program/project name.
            If cboSelProgName.Text <> "" Then
                ' Check whether the user enter a correct year format.
                If Len(txtYearBudPlan.Text) = 4 Then
                    ' Declare a new command to get program/project id.
                    Dim cmdGetProgID As New OleDbCommand
                    With cmdGetProgID
                        .Connection = cnnDonorDb
                        .CommandType = CommandType.Text
                        .CommandText = "SELECT tblProgName.ProgID FROM tblProgName WHERE tblProgName.OrgName LIKE '" & cboSelOrgName.Text & "' AND tblProgName.ProgName LIKE '" & cboSelProgName.Text & "'"
                    End With

                    ' Open the connection.
                    Try
                        cmdGetProgID.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
                    Dim drdGetProgID As OleDbDataReader = cmdGetProgID.ExecuteReader
                    If Not drdGetProgID Is Nothing Then
                        drdGetProgID.Read()
                        ' Get program/project id from the system.
                        strProgID = drdGetProgID(0).ToString
                        ' Close the connection
                        cmdGetProgID.Connection.Close()

                        ' Add an information on the form to the program/project budget.
                        ' Declare the new command.
                        Dim cmdAddProgBudInfo As New OleDbCommand
                        With cmdAddProgBudInfo
                            .Connection = cnnDonorDb
                            .CommandType = CommandType.Text
                            .CommandText = "INSERT INTO tblProgBudget (tblProgBudget.[ProgID], tblProgBudget.[Year], tblProgBudget.[GovContrib], tblProgBudget.[OrgContrib]) VALUES (" & Val(strProgID) & ", " & Val(txtYearBudPlan.Text) & ", " & Val(txtGovCont.Text) & ", " & Val(txtOwnCont.Text) & ")"
                        End With

                        ' Open the connection.
                        Try
                            cmdAddProgBudInfo.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
                        ' *********************************************
                        '
                        ' PROBLEM REMAIN IN HERE
                        ' 
                        ' *********************************************
                        ' Add an information to the database.
                        cmdAddProgBudInfo.ExecuteNonQuery()
                        ' Close the connection.
                        cmdAddProgBudInfo.Connection.Close()
                        ' Clear an information from the variable.
                        strProgID = ""
                        ' Inform the user after success add an information into the database system.
                        MessageBox.Show("The program/project budget for the year " & Trim(txtYearBudPlan.Text) & " and its relevant information are successfully added into the database system." & ControlChars.CrLf & "The system will clear an information on the form in order to prepare to add another year of program/project budget.", "Add Year of Program/Project Budget", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        ' Clear an information on the form.
                        txtYearBudPlan.Text = ""
                        txtGovCont.Text = ""
                        txtOwnCont.Text = ""
                    ElseIf drdGetProgID Is Nothing Then
                        MessageBox.Show("The program/project '" & cboSelProgName.Text & "' from '" & cboSelOrgName.Text & "' organization does not exist in the database system." & ControlChars.CrLf & "Please verify your an information of this program/project again.", "Program/Project not exixt in database", MessageBoxButtons.OK, MessageBoxIcon.Stop)
                    End If
                Else
                    MessageBox.Show("The year of budget plan require you to enter four digit format." & ControlChars.CrLf & "Example: This year is " & Format(Year(Now()), "YYYY") & ".", "Invalid Year Digit", MessageBoxButtons.OK, MessageBoxIcon.Stop)
                    txtYearBudPlan.Focus()
                End If
            ElseIf cboSelProgName.Text = "" Then
                MessageBox.Show("You didn't select any program/project.", "Require Selected Program/Project", MessageBoxButtons.OK, MessageBoxIcon.Stop)
            End If
        ElseIf cboSelOrgName.Text = "" Then
            MessageBox.Show("You didn't select any organization name.", "Require Selected Organization", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        End If
    End Sub


When I try to run, there is an except occure as the below detail technical information:

System.Data.OleDb.OleDbException was unhandled<br />
  ErrorCode=-2147217900<br />
  Message="The INSERT INTO statement contains the following unknown field name: 'tblProgBudget.ProgID'.  Make sure you have typed the name correctly, and try the operation again."<br />
  Source="Microsoft JET Database Engine"<br />
  StackTrace:<br />
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)<br />
       at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)<br />
       at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)<br />
       at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)<br />
       at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()<br />
       at DIC_Donor_Database.frmProgBudget.btnAddProg_Click(Object sender, EventArgs e) in C:\Documents and Settings\roathkanel\My Documents\Visual Studio 2005\Projects\DIC Donor Database\DIC Donor Database\frmProgBudget.vb:line 182<br />
       at System.Windows.Forms.Control.OnClick(EventArgs e)<br />
       at System.Windows.Forms.Button.OnClick(EventArgs e)<br />
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)<br />
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
       at System.Windows.Forms.Control.WndProc(Message& m)<br />
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)<br />
       at System.Windows.Forms.Button.WndProc(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
       at System.Windows.Forms.Application.Run(ApplicationContext context)<br />
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()<br />
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()<br />
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)<br />
       at DIC_Donor_Database.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81<br />
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)<br />
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br />
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br />
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
       at System.Threading.ThreadHelper.ThreadStart()


I feel that I enter the correct table and field name (because it copie the table name and field name from the database). But I can't run this code successfully.

Please give me some advice!!!
AnswerRe: Err when add record into database Pin
Christian Graus22-Aug-07 16:41
protectorChristian Graus22-Aug-07 16:41 
GeneralRe: Err when add record into database Pin
Mekong River22-Aug-07 16:47
Mekong River22-Aug-07 16:47 
QuestionRe: Err when add record into database Pin
Vimalsoft(Pty) Ltd22-Aug-07 23:28
professionalVimalsoft(Pty) Ltd22-Aug-07 23:28 
AnswerRe: Err when add record into database Pin
Mekong River22-Aug-07 23:57
Mekong River22-Aug-07 23:57 
GeneralRe: Err when add record into database Pin
Vimalsoft(Pty) Ltd23-Aug-07 0:15
professionalVimalsoft(Pty) Ltd23-Aug-07 0:15 
GeneralRe: Err when add record into database Pin
Dave Kreskowiak23-Aug-07 3:14
mveDave Kreskowiak23-Aug-07 3:14 
QuestionDelegates [modified] Pin
ASPnoob22-Aug-07 13:02
ASPnoob22-Aug-07 13:02 
AnswerRe: Delegates Pin
Christian Graus22-Aug-07 15:52
protectorChristian Graus22-Aug-07 15:52 
QuestionHighlighting text in a webbrowser control Pin
Ahmad Zaidi22-Aug-07 11:09
Ahmad Zaidi22-Aug-07 11:09 
AnswerRe: Highlighting text in a webbrowser control Pin
nlarson1122-Aug-07 11:28
nlarson1122-Aug-07 11:28 
QuestionMost Efficient Data Control Pin
errorfunktion22-Aug-07 8:59
errorfunktion22-Aug-07 8:59 
AnswerRe: Most Efficient Data Control Pin
Luc Pattyn22-Aug-07 14:10
sitebuilderLuc Pattyn22-Aug-07 14:10 
GeneralRe: Most Efficient Data Control Pin
errorfunktion22-Aug-07 18:13
errorfunktion22-Aug-07 18:13 
GeneralRe: Most Efficient Data Control Pin
Dave Kreskowiak23-Aug-07 3:10
mveDave Kreskowiak23-Aug-07 3:10 
QuestionDataGrid Record Loop. Pin
Smokeywade22-Aug-07 8:27
Smokeywade22-Aug-07 8:27 
AnswerRe: DataGrid Record Loop. Pin
jchigg200022-Aug-07 9:00
jchigg200022-Aug-07 9:00 
GeneralRe: DataGrid Record Loop. Pin
Smokeywade22-Aug-07 9:49
Smokeywade22-Aug-07 9:49 

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.