When i compiled these two source files, it gives me an error saying: Inaccesssible Due to its protection level.
Expand|Select|Wrap|Line Numbers
- ------------Base Class-----------------
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Configuration;
- using System.Data.SqlClient;
- namespace BDIC.Data
- {
- class DataAccess
- {
- protected string strConnect;
- public DataAccess()
- {
- }
- /// <summary>
- /// Please see the App.config file
- /// </summary>
- static DataAccess()
- {
- strConnect = ConfigurationSettings.AppSettings["DbConnection"];
- }
- /// <summary>
- /// Gets a SqlConnection to the local sqlserver
- /// </summary>
- /// <returns>SqlConnection</returns>
- protected SqlConnection GetConnection()
- {
- SqlConnection oConnection = new SqlConnection(strConnect);
- return oConnection;
- }
- }
- }
- -------inherited Class --------
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- using System.Data.SqlClient;
- namespace BDIC.Data
- {
- class DataOperation:DataAccess
- {
- public DataOperation()
- {
- }
- /// <summary>
- /// inserts a new row in to the table "person"
- /// </summary>
- /// <param name="strName"></param>
- /// <param name="strCName"></param>
- /// <param name="nWeekHour"></param>
- /// <param name="strPassword"></param>
- /// <param name="strEMail"></param>
- /// <param name="nAlreadyIn">returns the number of rows, which fulfill before insertation the condition EMail=strEMail</param>
- public void createJob(string customerName, string customerPhone, string truckMake,
- string truckModel, string registration, string damageDescription,
- DateTime deadLine)
- {
- //nAlreadyIn = 0;
- // Establish Connection
- using (SqlConnection oConnection = GetConnection())
- {
- // build the command
- using (SqlCommand oCommand = new SqlCommand("CreateJob", oConnection))
- {
- oCommand.CommandType = CommandType.StoredProcedure;
- // Parameters
- SqlParameter paraName = new SqlParameter("@CustomerName", SqlDbType.Char, 50);
- paraName.Value = customerName;
- oCommand.Parameters.Add(paraName);
- SqlParameter paraCustomerPhone = new SqlParameter("@CustomerPhone", SqlDbType.Char, 50);
- paraCustomerPhone.Value = customerPhone;
- oCommand.Parameters.Add(paraCustomerPhone);
- SqlParameter paraTruckMake = new SqlParameter("@TruckMake", SqlDbType.Int, 2);
- paraTruckMake.Value = truckMake;
- oCommand.Parameters.Add(paraTruckMake);
- SqlParameter paraTruckModel = new SqlParameter("@TruckModel", SqlDbType.Char, 50);
- paraTruckModel.Value = truckModel;
- oCommand.Parameters.Add(paraTruckModel);
- SqlParameter paraRegistration = new SqlParameter("@Registration", SqlDbType.Char, 50);
- paraRegistration.Value = registration;
- oCommand.Parameters.Add(paraRegistration);
- SqlParameter paraDeadLine = new SqlParameter("@DeadLine", SqlDbType.Char, 50);
- paraDeadLine.Value = deadLine;
- oCommand.Parameters.Add(paraDeadLine);
- /*
- SqlParameter paraAlreadyIn = new SqlParameter("@AlreadyIn", SqlDbType.Int, 2);
- paraAlreadyIn.Direction = ParameterDirection.Output;
- oCommand.Parameters.Add(paraAlreadyIn);
- */
- try
- {
- oConnection.Open();
- oCommand.ExecuteNonQuery();
- //nAlreadyIn = (int)paraAlreadyIn.Value;
- }
- catch (Exception oException)
- {
- throw oException;
- }
- }
- }
- }
- }
- }
when i created a DataOperation object
DataOperation data = new DataOperation();
it said BDIC.Data.DataOperation is inaccessbile due to its protection level
and its also said DataOperation contructor does not define ( Do we really need to put anything in there? in my case i dont think i need too) and its last error said "createJob is not in the defintion.
Please explain for me..