overflow in C# (visual Studio) where tryingt oinsert in database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bradman1861
    New Member
    • Dec 2009
    • 1

    overflow in C# (visual Studio) where tryingt oinsert in database

    hello i am getting a overflow error when I try to run this:


    here is the error:
    Code:
    System.Data.OleDb.OleDbException was unhandled
      Message="Overflow"
      Source="Microsoft JET Database Engine"
      ErrorCode=-2147217833
      StackTrace:
           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
           at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
           at WindowsApplication1.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Brad\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs:line 55
           at System.Windows.Forms.Control.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(Form mainForm)
           at WindowsApplication1.Program.Main() in C:\Documents and Settings\Brad\Desktop\WindowsApplication1\WindowsApplication1\Program.cs:line 17
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()


    here is the code:
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data.OleDb;
    using System.Configuration;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsApplication1
    {
    
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private OleDbConnection connection;
            private OleDbDataAdapter adapter;
            private OleDbCommand command;
    
            private void Form1_Load(object sender, EventArgs e)
            {
                
            }
    
            private void tabPage1_Click(object sender, EventArgs e)
            {
    
            }
    
            private void ConnectToDB()
            {
                connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" +
                    "Data Source=" + @"C:\Documents and Settings\Brad\Desktop\WindowsApplication1\WindowsApplication1\CD DATABASE.mdb");
                connection.Open();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                ConnectToDB();
                OleDbCommand objCmd;
                String strSQLCommand = "INSERT INTO CLIENT VALUES ('" + CLIENT_NUMBER.Text + "','" + CLIENT_LAST_NAME.Text + "','" + FIRST_NAME.Text + "','" + CLIENT_ADDRESS_1.Text + "','" + CLIENT_ADDRESS_2.Text + "','" + CITY.Text + "','" + STATE.Text + "','" + ZIP.Text + "','" + PHONE_NUMBER.Text + "','" + PREF_PAYMENT.Text + "','" + PREF_ACCOUNT.Text + "','" + MUSIC_TYPE.Text + "')";
                objCmd = new OleDbCommand(strSQLCommand, connection);
                objCmd.ExecuteNonQuery();
                label4.Text = "Your Info has been Added";
                CLIENT_NUMBER.Text = " ";
                CLIENT_LAST_NAME.Text = " ";
                CLIENT_FIRST_NAME.Text = " ";
                CLIENT_ADDRESS_2.Text = " ";
                CLIENT_ADDRESS_1.Text = " ";
                CITY.Text = " ";
                STATE.Text = " ";
                ZIP.Text = " ";
                PHONE_NUMBER.Text = " ";
                PREF_PAYMENT.Text = " ";
                PREF_ACCOUNT.Text = " ";
                MUSIC_TYPE.Text = " ";
            }
    The Access database is Access 2003 and VS 2005 professional

    -Brad
    Last edited by tlhintoq; Dec 7 '09, 02:05 AM. Reason: [CODE] ...your code here... [/CODE] tags added
Working...