OleDbException

This is a discussion on OleDbException within the C# Programming forums, part of the General Programming Boards category; i am getting a OleDbException that states "No value for one or more required parameters" here is the code: Code: ...

  1. #1
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356

    Question OleDbException

    i am getting a OleDbException that states "No value for one or more required parameters"

    here is the code:

    Code:
    using System;
    using System.Windows.Forms;
    using System.Data.OleDb;
    using System.Data;
    
    class CompanyDetails
    {
    	
    	public CompanyDetails(){}
    	
    	public CompanyDetails(string companyName, string add1, string add2, string phone, 
    		string fax,string city , string state, string email, string website, 
    		string cPerson, string cPhone )
    	{
    		this.companyName = companyName;
    		this.add1 = add1;
    		this.add2 = add2;
    		this.phone = phone;
    		this.fax = fax;
    		this.city = city;
    		this.state = state;
    		this.email = email;
    		this.website = website;
    		this.cPerson = cPerson;
    		this.cPhone = cPhone;
    	}
    
    	public void enterCompanyDetails()
    	{
    		OleDbConnection conn = null;
    
    		try
    		{
    			conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;
    										User Id =; Password=; 
    										Data Source=C:\professional\pro.mdb" );
    			conn.Open();
    
    			OleDbCommand cmd = conn.CreateCommand();
    			cmd.CommandText = @"INSERT INTO Company( CompanyName,Address1,Address2,
    													 PhoneNo,FaxNo,City,State,Email,
    													 Website,ContactPerson,ContactPersonPhone )
    								VALUES (companyName, add1, add2, phone, fax, city, state,email,
    										website,cPerson,cPersonPhone )";
     
    			cmd.ExecuteNonQuery();
    		}
    
    		catch(OleDbException error )
    		{
    			MessageBox.Show("OleDbException: " + error.Message,"Error",
    				MessageBoxButtons.OK,MessageBoxIcon.Error );
    		}
    		finally
    		{
    			if ( conn != null )
    				conn.Close();
    		}
    	
    	}
    }
    and one more thing i am using the CalenderMonth component how will it return the date in string i used clenderMonth.ToString() but it dosnt work the way i want it to ...

  2. #2
    id id
    Guest
    Try leaving out the username and password parameters if you do not have them:

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\professional\pro.mdb"

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21