what is the use of datacontract? - c#

here ,i am using wpf .in my code there is one folder named by datacontect:and it contain code as below:
public interface IAccountCategoryDataSource
{
bool Add(AccountCategory accountCategory);
bool Update(AccountCategory accountCategory);
bool Remove(AccountCategory accountCategory);
AccountCategory GetById(int id);
AccountCategory GetByName(string name);
IEnumerable<AccountCategory> GetByParentCategory(AccountCategory category);
IEnumerable<AccountCategory> GetTopLevelCategories();
IEnumerable<AccountCategory> GetBySearchTerm(string searchTerm);
IEnumerable<AccountCategory> GetAll();
event EventHandler<ObjectAddedEventArgs> AccountCategoryAdded;
event EventHandler<ObjectUpdatedEventArgs> AccountCategoryUpdated;
event EventHandler<ObjectRemovedEventArgs> AccountCategoryRemoved;
}
ther is also other folder datasource: here datasource is related to the above file
public class AccountCategoryDataSource : IAccountCategoryDataSource
{
public int ReferenceCountOf(AccountCategory accountCategory)
{
int count = 0;
string query = "select count(*) from account_categories where parent_category=" + accountCategory.Id
+ " union select count(*) from accounts where category=" + accountCategory.Id;
DataTable dataTable = SQLiteHelper.ExecuteQuery(query);
foreach (DataRow row in dataTable.Rows)
{
count += Convert.ToInt32(row[0]);
}
return count;
}
#region IAccountCategoryDataSource Members
public bool Add(AccountCategory accountCategory)
{
string query = "insert into account_categories(name, description, parent_category) values("
+ "'" + accountCategory.Name + "', "
+ "'" + accountCategory.Description + "', "
+ accountCategory.ParentCategory.Id
+ ")";
accountCategory.Id = SQLiteHelper.ExecuteInsert(query);
if (accountCategory.Id > 0)
{
if (AccountCategoryAdded != null)
{
AccountCategoryAdded(this, new ObjectAddedEventArgs(accountCategory));
}
return true;
}
return false;
}
public bool Update(AccountCategory accountCategory)..................
and this related to the model floder's accountcategory class
public class AccountCategory : IDataErrorInfo, IValidable
{
#region State Properties
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public AccountCategory ParentCategory { get; set; }
public bool Builtin { get; set; }
}
and for execution :helper class
public class SQLiteHelper
{
public static DataTable ExecuteQuery(string query)
{
DataTable dataTable = new DataTable();
SQLiteConnection conn = new SQLiteConnection(Settings.Default["DBConnectionString"].ToString());
using (SQLiteCommand cmd = new SQLiteCommand(query, conn))
{
conn.Open();
SQLiteDataReader reader = cmd.ExecuteReader();
dataTable.Load(reader);
reader.Close();
conn.Close();
}
return dataTable;
}..........................
plz explain brief role of data contract.and how it interact with helper,model,and dataSouce . is it provide linq to sql concept?

DataContract is a WCF concept. It is unrelated to WPF (until it is communicating with WCF).
From your code, seems like it it just a Folder which contain Data Access Layer classes and seems unrelated to WCF

Related

Unable to get all records displayed in report viewer

[edit:I added the data visualizer]
I have a teacher's registration where records are being input using an insert button in a SQL database as such
private void insertdata(object sender, RoutedEventArgs e)
{
try
{
string name = name_field.Text;
string email = email_field.Text;
string id = id_field.Text;
string gender;
if (male.IsChecked == true)
{
gender = "M";
}
else
gender = "F";
if (String.IsNullOrEmpty(dob.Text))
{
string fe = "01/01/1900 12:00:00 AM";
dt = Convert.ToDateTime(fe);
}
else
{
dt = Convert.ToDateTime(dob.Text);
}
var rich1 = new TextRange(this.history.Document.ContentStart, this.history.Document.ContentEnd);
string teach_history = rich1.Text;
var rich2 = new TextRange(this.achievement.Document.ContentStart, this.achievement.Document.ContentEnd);
string teach_achievement = rich2.Text;
connect();
con.Open();
string saved = "insert into teacher_details ([Teacher ID],Name,Gender,Email,[Date of Birth],Employment History,Achievements)values('" + id + "', '" + name + "','" + gender + "','" + email + "','" + dt + "','" + teach_history + "','" + teach_achievement + "')";
SqlCommand cmd = new SqlCommand(saved, con);
cmd.ExecuteReader();
con.Close();
MessageBox.Show("record is added");
}
catch(Exception ex)
{
MessageBox.Show("error occured " + ex);
}
I have id,gender,name,email,history,achievements,date of birth as my fields. I made a class for this as follows:
class Teacherdetail
{
public string id { get; set; }
public string name { get; set; }
public string email { get; set; }
public string gender { get; set; }
public string history { get; set; }
public string acheive { get; set; }
public DateTime dob { get; set; }
}
in my rdlc report i used object as my dataset and selected Teacherdetail. Then I made a table as follow:
i then have a button view report where I call details into the reportviewer that is called teacherreport
ReportDataSource reportDataSource = new ReportDataSource();
connect();
con.Open();
SqlDataAdapter adp = new SqlDataAdapter("select [Teacher ID],Name,Gender,email,[Date of Birth],[Employment History],Achievements from teacher_details", con);
DataTable newtab = new DataTable();
adp.Fill(newtab);
reportDataSource.Name = "DataSet1";
reportDataSource.Value = newtab;
teacherreport.LocalReport.ReportPath = "C:\\Users\\Preeti Rawat\\Documents\\Visual Studio 2012\\Projects\\STDNT\\STDNT\\teacherreport.rdlc";
teacherreport.LocalReport.DataSources.Add(reportDataSource);
teacherreport.LocalReport.Refresh();
teacherreport.RefreshReport();
My problem is that id, history, name and achieve are missing.
When I debug the program, in my data visualizer it does show that the information is passing through.
but it is still not appearing when in the program. What can the problem be and how can I fix it? Thank you ^^
For your specific question, in your insertdata, you are calling ExecuteReader to insert a new record, and it's wrong. You need to call ExecuteNonQuery to INSERT, UPDATE, DELETE actions.
Also, in :
string saved = "insert into teacher_details ([Teacher ID],Name,Gender,Email,[Date of Birth],Employment History,Achievements)values('" + id + "', '" + name + "','" + gender + "','" + email + "','" + dt + "','" + teach_history + "','" + teach_achievement + "')";
this should return a SQL error, since Employment History not contained by brackets [].
Here is a revised version of your method. (I've tried to kept the same work).
var name = name_field.Text;
var name = name_field.Text;
var email = email_field.Text;
var id = id_field.Text;
var gender = male.IsChecked ? "M" : "F";
var dt = DateTime.TryParse(dob.Text, out DateTime result) ? result : new DateTime(1900,1,1);
var teach_history = new TextRange(this.history.Document.ContentStart, this.history.Document.ContentEnd).Text;
var teach_achievement = new TextRange(this.achievement.Document.ContentStart, this.achievement.Document.ContentEnd).Text;
const string query = "INSERT INTO teacher_details([Teacher ID],Name,Gender,Email,[Date of Birth],[Employment History],Achievements) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}'); ";
var saved = string.Format(query, id, name, gender, email, dt.ToString("yyyy-MM-ddThh:mm:ss"), teach_history, teach_achievement)
connect();
con.Open();
using(var cmd = new SqlCommand(saved, con))
{
cmd.ExcuteNonQuery();
}
con.Close();
MessageBox.Show("record is added");
you should use using blocks on SqlConnection or Dispose your connection manually. Also, I suggest you start using Entity Framework instead for database operations.
For the report part, you need to do this :
var table = new DataTable();
const string query = "SELECT [Teacher ID],Name,Gender,email,[Date of Birth],[Employment History],Achievements from teacher_details";
connect();
con.Open();
var adapter = new SqlDataAdapter(query, con);
adapter.Fill(table);
var reportDataSource = new ReportDataSource("Dataset1", table);
teacherreport.LocalReport.ReportPath = "C:\\Users\\Preeti Rawat\\Documents\\Visual Studio 2012\\Projects\\STDNT\\STDNT\\teacherreport.rdlc";
teacherreport.LocalReport.DataSources.Clear();
teacherreport.LocalReport.DataSources.Add(reportDataSource);
teacherreport.LocalReport.Refresh();
teacherreport.RefreshReport();
The reason this was not working was that the class names were different from the table's field name. They have to be the same. So I changed column names of my database table so that it looks like this:
Teacher_ID,Name,Gender,Email,Date_of_Birth,Employment_History,Achievements
and my class looks like this:
public int Teacher_ID { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string email { get; set; }
public DateTime Date_of_Birth { get; set; }
public string Employment_History { get; set; }
public string Achievements { get; set; }

How to get many field on the Query of webservice

I am making a web service get data from sql server. I need to get many fields from the sql server, but I can only get one field, which is the Currancy Name
namespace WebApplication2
{
public class DataHelper
{
public static string GetCurrency(string currencyCode)
{
string currencyName = "";
SqlConnection con = new SqlConnection(#"Data Source=WEB3\SHAREPOINT;Initial Catalog=WSS_Search_WEB3;Integrated Security=True");
SqlCommand cmd = new SqlCommand("select PO_NUMBER,PO_STATUS from View_1 where PO_HEADER_ID ='" + currencyCode.ToUpper() + "'", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
currencyName = dr["PO_NUMBER"].ToString();
}
dr.Close();
con.Close();
return currencyName;
}
}
}
I need to get the PO_Number & PO Status from the Query
As I understand you need to return not only PO_NUMBER, but also PO_STATUS, and as I understand you want to return both values.
I suggest you make model that represent what you want to return.
So for that we make a model class call it for instance POModel:
public class POModel
{
public string currencyName { get; set; } // PO_Number
public string statusName { get; set; } // PO_Status
}
Than fetch the values from SQL as you did and return object in stead of string.
Here would you final code looks like, of course naming and all the stuff you can change the way if fits best:
public class DataHelper
{
public static POModel GetCurrency(string currencyCode)
{
//string currencyName = "";
var poModel = new POModel();
SqlConnection con = new SqlConnection(#"Data Source=WEB3\SHAREPOINT;Initial Catalog=WSS_Search_WEB3;Integrated Security=True");
SqlCommand cmd = new SqlCommand("select PO_NUMBER,PO_STATUS from View_1 where PO_HEADER_ID ='" + currencyCode.ToUpper() + "'", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
poModel.currencyName = dr["PO_NUMBER"].ToString();
poModel.statusName = dr["PO_STATUS"].ToString();
}
dr.Close();
con.Close();
//return currencyName;
return poModel;
}
}
public class POModel
{
public string currencyName { get; set; }
public string statusName { get; set; }
}
One option is to return an array that contains the two values. Notice string[]:
public static string[] GetCurrency(string currencyCode)
Similar to how you declared string currencyName = "";, instead make an array variable:
string[] poData = new string[2];
Since this looks like it should return a single row, I would not loop. Just do a Read():
dr.Read();
poData[0] = dr["PO_NUMBER"].ToString(); //poData[] will have to be declared in your method
poData[1] = dr["PO_STATUS"].ToString();
....
return poData;

C# my class returns nothing from SQL Server database

This is my class.
I have a method called retrievecinemainfo which connects with my other class called Bioscoopinfo. This method (retrievecinemainfo) is declared at my main form.
The problem is that when I want to retrieve the data from the database, it doesn't return it into the textboxes, it does collect the right data because I have seen it in the debugger. But when it passes my class constructor called bioscoopinfo, the values are empty all of a sudden and it doesn't return anything.
Can anyone please help?
class sqlconnectie
{
public Bioscoopinfo retrievecinemainfo (string Locatie, string Bioscoop, string Tijd)
{
Bioscoopinfo biosinfo = null;
SqlDataReader myreader;
try
{
con.Open();
myreader = cmd.ExecuteReader();
if (myreader.Read())
{
Locatie = myreader.GetString(1);
Bioscoop = myreader.GetString(2);
Tijd = myreader.GetString(3);
biosinfo = new Bioscoopinfo(Locatie, Bioscoop, Tijd);
string strpath = Application.StartupPath;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return biosinfo;
}
}
and this here is my class where the values eventually return nothing:
class Bioscoopinfo
{
public string locatie { get; set; }
public string bioscoop { get; set; }
public string tijd { get; set; }
public Bioscoopinfo(string locatie, string bioscoop, string tijd)
{
this.locatie = "place";
this.bioscoop = "cinema";
this.tijd = "19:00";
}
}
and this here is the code where my code will actually get used
connectie = new sqlconnectie();
connectie.stringcommand("SELECT * FROM Bios where Locatie = '" + comboBox1.Text + "' ");
string bioscoop = tbbioscoop.Text;
string locatie = tblocatie.Text;
string tijd = tbtijd.Text;
connectie.retrievecinemainfo(bioscoop, locatie, tijd);

WCF-ServiceReference Response gives ArrayOfXElement instead of the object

I am trying to write login app.
My problem is that Service gives me ArrayOfXElement instead of an object.
And I do not know how to get to this object.
Here is the code:
StartPage.xaml.cs
using (...);
namespace MyFirstProject
{
public sealed partial class StartPage : Page
{
ServiceReference1.Service1Client MyService;
public StartPage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
MyService = new ServiceReference1.Service1Client();
}
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
ServiceReference1.GetSinglePassCmdResponse h = MyService.GetSinglePassCmdAsync(new ServiceReference1.Pass { nickName = tBoxNick_log.Text }).Result;
Now I thought that in h I have object and I can do smth like this:
testBlock.Text = "nickname: " + h.nickname + " password: " + h.pass;
}}}
but I got error that GetSinglePassCmdResponse does not contain a definition for 'nickname'
IService1.cs
[OperationContract]
Pass GetSinglePassCmd(Pass Pass);
[DataContract]
public partial class Pass
{
[DataMember]
public string nickName { get; set; }
[DataMember]
public string password { get; set; }
[DataMember]
public Nullable<System.DateTime> lastLogDate { get; set; }
Service1.svc
public Pass GetSinglePassCmd(Pass Pass)
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand cmd = new SqlCommand("SELECT * FROM Passwords WHERE nickName=#nickName", con);
cmd.Parameters.AddWithValue("#nickName", Passwords.nickName);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
cmd.ExecuteNonQuery();
con.Close();
Pass pass = new Pass();
int i = 0;
if (ds.Tables[0].Rows.Count > 0)
{
//assign dataset values to array
pass.nickName = ds.Tables[0].Rows[i]["nickName"].ToString();
pass.password = ds.Tables[0].Rows[i]["password"].ToString();
pass.lastLogDate = DateTime.Parse(ds.Tables[0].Rows[i]["lastLogDate"].ToString());
}
else pass = null;
return pass;
}
And in MyFirstProject->ServiceReferences->ServiceReference1->Reference.cs->GetSinglePassCmdResponse I got
public partial class GetSinglePassCmdResponse {
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public MyFirstProject.ServiceReference1.ArrayOfXElement GetSinglePassCmdResult;
public GetSinglePassCmdResponse() {
}
public GetSinglePassCmdResponse(MyFirstProject.ServiceReference1.ArrayOfXElement GetSinglePassCmdResult) {
this.GetSinglePassCmdResult = GetSinglePassCmdResult;
}
}
Could anyone help me please... ?
PS I have also tried this:
testBlock.Text = "nickname: " + h.GetSinglePassCmdResult.nickname + " password: " + h.GetSinglePassCmdResult.pass;

C# 'Class.IMDb' does not contain a constructor that takes 0 arguments

I have class which gets info from Imdb.com about movie ant stores info in class variables.I have another class which writes info about movie in database. So, I want to make inheritence and get variables info and save into database. But I am getting error: 'FilmuBiblioteka.IMDb' does not contain a constructor that takes 0 arguments
Here is my code:
public class IMDb
{
public bool status { get; set; }
public string Id { get; set; }
public string Title { get; set; }
public string OriginalTitle { get; set; }
public string Year { get; set; }
public string Rating { get; set; }
public ArrayList Genres { get; set; }
public ArrayList Directors { get; set; }
public ArrayList Cast { get; set; }
public string Plot { get; set; }
public string Poster { get; set; }
public string PosterLarge { get; set; }
public string PosterFull { get; set; }
public string Runtime { get; set; }
public ArrayList Languages { get; set; }
public ArrayList Countries { get; set; }
public string ImdbURL { get; set; }
//Search Engine URLs
private string GoogleSearch = "http://www.google.com/search?q=imdb+";
private string BingSearch = "http://www.bing.com/search?q=imdb+";
private string AskSearch = "http://www.ask.com/web?q=imdb+";
private Func<string> toString;
private bool v;
//Constructor
public IMDb(string MovieName, bool GetExtraInfo = true)
{
string imdbUrl = getIMDbUrl(System.Uri.EscapeUriString(MovieName));
status = false;
if (!string.IsNullOrEmpty(imdbUrl))
{
parseIMDbPage(imdbUrl, GetExtraInfo);
}
}
public IMDb(Func<string> toString, bool v)
{
this.toString = toString;
this.v = v;
}
//Get IMDb URL from search results
private string getIMDbUrl(string MovieName, string searchEngine = "google")
{
string url = GoogleSearch + MovieName; //default to Google search
if (searchEngine.ToLower().Equals("bing")) url = BingSearch + MovieName;
if (searchEngine.ToLower().Equals("ask")) url = AskSearch + MovieName;
string html = getUrlData(url);
ArrayList imdbUrls = matchAll(#"<a href=""(http://www.imdb.com/title/tt\d{7}/)"".*?>.*?</a>", html);
if (imdbUrls.Count > 0)
return (string)imdbUrls[0]; //return first IMDb result
else if (searchEngine.ToLower().Equals("google")) //if Google search fails
return getIMDbUrl(MovieName, "bing"); //search using Bing
else if (searchEngine.ToLower().Equals("bing")) //if Bing search fails
return getIMDbUrl(MovieName, "ask"); //search using Ask
else //search fails
return string.Empty;
}
//Parse IMDb page data
private void parseIMDbPage(string imdbUrl, bool GetExtraInfo)
{
string html = getUrlData(imdbUrl + "combined");
Id = match(#"<link rel=""canonical"" href=""http://www.imdb.com/title/(tt\d{7})/combined"" />", html);
if (!string.IsNullOrEmpty(Id))
{
status = true;
Title = match(#"<title>(IMDb \- )*(.*?) \(.*?</title>", html, 2);
OriginalTitle = match(#"title-extra"">(.*?)<", html);
Year = match(#"<title>.*?\(.*?(\d{4}).*?\).*?</title>", html);
Rating = match(#"<b>(\d.\d)/10</b>", html);
Genres = matchAll(#"<a.*?>(.*?)</a>", match(#"Genre.?:(.*?)(</div>|See more)", html));
Directors = matchAll(#"<td valign=""top""><a.*?href=""/name/.*?/"">(.*?)</a>", match(#"Directed by</a></h5>(.*?)</table>", html));
Cast = matchAll(#"<td class=""nm""><a.*?href=""/name/.*?/"".*?>(.*?)</a>", match(#"<h3>Cast</h3>(.*?)</table>", html));
Plot = match(#"Plot:</h5>.*?<div class=""info-content"">(.*?)(<a|</div)", html);
Runtime = match(#"Runtime:</h5><div class=""info-content"">(\d{1,4}) min[\s]*.*?</div>", html);
Languages = matchAll(#"<a.*?>(.*?)</a>", match(#"Language.?:(.*?)(</div>|>.?and )", html));
Countries = matchAll(#"<a.*?>(.*?)</a>", match(#"Country:(.*?)(</div>|>.?and )", html));
Poster = match(#"<div class=""photo"">.*?<a name=""poster"".*?><img.*?src=""(.*?)"".*?</div>", html);
if (!string.IsNullOrEmpty(Poster) && Poster.IndexOf("media-imdb.com") > 0)
{
Poster = Regex.Replace(Poster, #"_V1.*?.jpg", "_V1._SY200.jpg");
PosterLarge = Regex.Replace(Poster, #"_V1.*?.jpg", "_V1._SY500.jpg");
PosterFull = Regex.Replace(Poster, #"_V1.*?.jpg", "_V1._SY0.jpg");
}
else
{
Poster = string.Empty;
PosterLarge = string.Empty;
PosterFull = string.Empty;
}
ImdbURL = "http://www.imdb.com/title/" + Id + "/";
if (GetExtraInfo)
{
string plotHtml = getUrlData(imdbUrl + "plotsummary");
}
}
}
/*******************************[ Helper Methods ]********************************/
//Match single instance
private string match(string regex, string html, int i = 1)
{
return new Regex(regex, RegexOptions.Multiline).Match(html).Groups[i].Value.Trim();
}
//Match all instances and return as ArrayList
private ArrayList matchAll(string regex, string html, int i = 1)
{
ArrayList list = new ArrayList();
foreach (Match m in new Regex(regex, RegexOptions.Multiline).Matches(html))
list.Add(m.Groups[i].Value.Trim());
return list;
}
//Strip HTML Tags
static string StripHTML(string inputString)
{
return Regex.Replace(inputString, #"<.*?>", string.Empty);
}
//Get URL Data
private string getUrlData(string url)
{
WebClient client = new WebClient();
Random r = new Random();
//Random IP Address
client.Headers["X-Forwarded-For"] = r.Next(0, 255) + "." + r.Next(0, 255) + "." + r.Next(0, 255) + "." + r.Next(0, 255);
//Random User-Agent
client.Headers["User-Agent"] = "Mozilla/" + r.Next(3, 5) + ".0 (Windows NT " + r.Next(3, 5) + "." + r.Next(0, 2) + "; rv:2.0.1) Gecko/20100101 Firefox/" + r.Next(3, 5) + "." + r.Next(0, 5) + "." + r.Next(0, 5);
Stream datastream = client.OpenRead(url);
StreamReader reader = new StreamReader(datastream);
StringBuilder sb = new StringBuilder();
while (!reader.EndOfStream)
sb.Append(reader.ReadLine());
return sb.ToString();
}
}
public class filmai : IMDb
{
public System.Data.DataSet gauticonnection
{
get
{ return gauti(); }
}
private System.Data.DataSet gauti()
{
System.Data.SqlClient.SqlConnection sqlConnection1;
System.Data.SqlClient.SqlDataAdapter da;
sqlConnection1 = new System.Data.SqlClient.SqlConnection(#"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Darius\Documents\Visual Studio 2013\Projects\FilmuBiblioteka\FilmuBiblioteka\duombaze.mdf");
da = new SqlDataAdapter("select * from filmai", sqlConnection1);
DataSet ds = new DataSet();
da.Fill(ds, "Table");
try
{
sqlConnection1.Open();
da.Fill(ds);
}
catch (Exception e)
{
throw;
}
finally
{
if (sqlConnection1.State == System.Data.ConnectionState.Open)
sqlConnection1.Close();
}
return ds;
}
public void prideti()
{
System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection(#"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Darius\Documents\Visual Studio 2013\Projects\FilmuBiblioteka\FilmuBiblioteka\duombaze.mdf");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "INSERT filmai (Id, Pavadinimas, Metai, trukme, salis, kalba, reitingas, zanras, aktoriai, link, plot, rezisieriai) VALUES (Id, Title, Year, Runtime, Countries, Languages, Rating, Genres, Cast, ImdbURL, Plot, Directors)";
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
cmd.ExecuteNonQuery();
sqlConnection1.Close();
}
}
I'm getting error at this line: public class filmai : IMDb
As previously said in my comment the compliation error that you have is because the current constructor for your filmai class does not correctly call a constructor of your IMDb class.
To correctly inherit from a base class you must call it's constructor before your implemented constructor of the deriving class runs such as:
public filmai(string filmName)
: base(filmName, false)
{
}
This will call the base constructor of public IMDb(string MovieName, bool GetExtraInfo = true) with the film name that was provided to the filmai constructor and will say that it does not require extra information.
I'm not sure on your use-case though as it looks like filmai is purely for database access and IMDb is for requesting for a single film? But implementing a constructor on filmai and calling : base(...) will fix your issue just now.

Categories