|
Did you get this to work for you yet? By the way, it's called Huffman Tree
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have a question about the benefits of using linq to sql in a C# 2010 web application. I am asking that question since I am the only programmer at a small company that is making changes to the company website that was written originally by a contract shop that went out of business. This is the first time I have worked with linq to sql.
From my point of view, I just see linq as more performance overhead to slow down the performance of the website. The linq needs to be translated to sql by the .net application. Thus can you tell me what I am missing?
|
|
|
|
|
In a lot of cases, a well designed LINQ application is no less performant than a hand crafted SQL solution. You have to be aware of what you are doing, but when you do know, it's a pretty powerful technique.
|
|
|
|
|
Neh. The peformance is similar to hand rolling the code against SQL directly, but (as Pete has said) you need to know what you are doing. You can use SQL Queries, with LINQ to SQL, and the queries can be optimised in the usual way.
What is does bring in the ability not to need write yet another DAL Implementation, freeing you up to be more productive in other areas. I've not really used ADO.NET directly for a good few years now, nor have I felt the need to.
|
|
|
|
|
Hi,
If you can utilize LINQ perfectly then linq to sql will definitely improve your application performance. One more advantage is database dependency. you can provide multiple database support for your application like MySQL, MsSQL, etc....
You do not need to maintain two database query individually. Framework will manage that.
There are more features and both way have pros and cons. so you need to decide it from your application requirements.
Thanks
-amit
|
|
|
|
|
amitgajjar wrote: If you can utilize LINQ perfectly then linq to sql will definitely
improve your application performance.
Bold statement there. It MAY improve application performance, but if I write equally optimised SQL then I won't see an improvement.
|
|
|
|
|
Yes but my personal opinion is if we are with the latest trend or flow of the Microsoft evolution then we can win the race. As we can see Microsoft people concentrate on new things, so if you are planning for long term project then we should use latest one.
As good coding in Framework 2.0 is better then Bad in Framework 4.0
But i would like to know your personal opinion, if you have a long term project what will be your choice ?
-Amit
|
|
|
|
|
|
on codeplex it says this project is in progress. so can we rely on that ?
|
|
|
|
|
Yes. The in progress part means we are adding lots of new features to it - this really is an ongoing project. It's actually up and running here[^].
|
|
|
|
|
my project i used tcp server done by c# program and wp7 client tcp
i want ask if i can used wcf service (to remote DB on server ) with tcp in the same project ??????????????????????
|
|
|
|
|
Yeah, why wouldn't you be able to?
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace SSG
{
public partial class frmBusiness_Statement : Form
{
string[,] Plans;
int BranchId = 0;
string branchname = "";
string memberid = "";
int statementid = 0;
double TotalRecieptAmount = 0.0;
public frmBusiness_Statement()
{
InitializeComponent();
}
private void frmBusinessStatement_Load(object sender, EventArgs e)
{
dtpStatementDate.Value = DateTime.Now;
radNewBusiness_CheckedChanged(sender, new EventArgs());
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "SELECT CONCAT(branchname,' (',branchcode,')') AS branch FROM branches";
MySqlCommand cmd = new MySqlCommand(qry, con);
MySqlDataReader r = cmd.ExecuteReader();
cmbBranch.Items.Clear();
if (r.HasRows)
{
while (r.Read())
{
cmbBranch.Items.Add(r.GetString("branch"));
}
}
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void radMember_CheckedChanged(object sender, EventArgs e)
{
if (radMember.Checked)
{
lblMCE.Text = "Member ID";
lblMCEN.Text = "Member Name";
txtDesignation.Text = "";
}
else
{
lblMCE.Text = "Executive ID";
lblMCEN.Text = "Executive Name";
txtDesignation.Text = "Collection Executive";
}
}
private void radCE_CheckedChanged(object sender, EventArgs e)
{
radMember_CheckedChanged(sender, new EventArgs());
}
private void cmbBranch_SelectedIndexChanged(object sender, EventArgs e)
{
string branchcode = "";
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "SELECT branchid,branchcode,branchname FROM branches WHERE CONCAT(branchname,' (',branchcode,')') LIKE '" + cmbBranch.Text + "'";
MySqlCommand cmd = new MySqlCommand(qry, con);
MySqlDataReader r = cmd.ExecuteReader();
if (r.HasRows)
{
r.Read();
branchcode = r.GetString("branchcode");
branchname = r.GetString("branchname");
this.BranchId = r.GetInt32("branchid");
if (txtMemberID.Text.Length <= 4)
{
txtMemberID.Text = r.GetString("branchcode");
}
else
{
string prev = "";
prev = txtMemberID.Text.Substring(4);
if (prev.Length < 6)
{
prev = memberid;
}
txtMemberID.Text = r.GetString("branchcode") + prev;
}
}
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "SELECT IFNULL(MAX(statementid),0) AS statementid FROM business_statements";
MySqlCommand cmd = new MySqlCommand(qry, con);
MySqlDataReader r = cmd.ExecuteReader();
if (r.HasRows)
{
r.Read();
statementid = r.GetInt32("statementid") + 1;
}
lblStatementNo.Text = dtpStatementDate.Value.ToString("MMMyy").ToUpper() + "/" + GlobalVariables.GetFullNumber(statementid, 5) + "/" + branchcode;
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void txtMemberID_TextChanged(object sender, EventArgs e)
{
if (txtMemberID.Text.Length > 6)
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
/* Have to make change here! */
string qry;
if (radMember.Checked)
{
qry = "SELECT membername,(SELECT designationname FROM designations WHERE designationid=members.designationid) AS designation FROM members WHERE memberid=" + txtMemberID.Text.Substring(5);
}
else
{
qry = "SELECT cename AS membername,'Collection Executive' AS designation FROM collectionexecutives WHERE ceid=" + txtMemberID.Text.Substring(5);
}
MySqlCommand cmd = new MySqlCommand(qry, con);
MySqlDataReader r = cmd.ExecuteReader();
if (r.HasRows)
{
r.Read();
txtMemberName.Text = r.GetString("membername");
txtDesignation.Text = r.GetString("designation");
}
else
{
txtMemberName.Text = "";
txtDesignation.Text = "";
}
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void radRenewal_CheckedChanged(object sender, EventArgs e)
{
radNewBusiness_CheckedChanged(sender, new EventArgs());
}
private void fillPlans()
{
cmbPlan.Items.Clear();
cmbPlan.Items.Add("SID");
cmbPlan.Items.Add("RUC");
cmbPlan.Items.Add("PS");
if (radNewBusiness.Checked == true)
{
cmbPlan.Items.Add("FD");
cmbPlan.Items.Add("BBA");
}
}
private void radNewBusiness_CheckedChanged(object sender, EventArgs e)
{
if (radNewBusiness.Checked)
{
radCE.Enabled = false;
radMember.Checked = true;
grpInvestors.Visible = false;
}
else
{
radCE.Enabled = true;
grpInvestors.Visible = true;
}
fillPlans();
}
private void txtCustomerId_TextChanged(object sender, EventArgs e)
{
string branchcode = "";
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "SELECT branchid,branchcode,branchname FROM branches WHERE CONCAT(branchname,' (',branchcode,')') LIKE '" + cmbBranch.Text + "'";
MySqlCommand cmd = new MySqlCommand(qry, con);
MySqlDataReader r = cmd.ExecuteReader();
if (r.HasRows)
{
r.Read();
branchcode = r.GetString("branchcode");
branchname = r.GetString("branchname");
this.BranchId = r.GetInt32("branchid");
}
}
if (cmbPlan.Text == "SID")
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "SELECT customerid, agreementdate, accountname, refererid, tableno, dateofexpiry FROM investers_sid WHERE investeridsid LIKE '" + txtCustomerId.Text.Trim() + "' AND plan LIKE '" + cmbPlan.Text + "' ";
if (radCE.Checked == true)
{
qry += "AND ceid=" + txtMemberID.Text.Substring(5);
}
else
{
qry += "AND refererid=" + txtMemberID.Text.Substring(5);
}
MySqlCommand cmd = new MySqlCommand(qry, con);
MySqlDataReader r = cmd.ExecuteReader();
if (r.HasRows)
{
r.Read();
txtIvestorName.Text = r.GetString("accountname");
txtRMemberId.Text = r.GetString("refererid");
txtRAmount.Text = r.GetString("investment");
txtTableNo.Text = r.GetString("tableno");
dtpClosingDate.Value = r.GetDateTime("dateofexpiry");
FillHistory();
}
else
{
txtIvestorName.Text = "";
txtRMemberId.Text = "";
txtRAmount.Text = "";
txtLateFee.Text = "0";
txtTableNo.Text = "";
dtpClosingDate.Value = DateTime.Now;
dgInvestorHistory.DataSource = null;
}
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
txtIvestorName.Text = "";
txtRMemberId.Text = "";
txtRAmount.Text = "";
txtLateFee.Text = "0";
txtTableNo.Text = "";
dtpClosingDate.Value = DateTime.Now;
}
if (cmbPlan.Text == "RUC")
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "SELECT customerid, agreementdate, accountname, refererid, tableno, dateofexpiry FROM investers_ruc WHERE investeridruc LIKE '" + txtCustomerId.Text.Trim() + "' AND plan LIKE '" + cmbPlan.Text + "' ";
if (radCE.Checked == true)
{
qry += "AND ceid=" + txtMemberID.Text.Substring(5);
}
else
{
qry += "AND refererid=" + txtMemberID.Text.Substring(5);
}
MySqlCommand cmd = new MySqlCommand(qry, con);
MySqlDataReader r = cmd.ExecuteReader();
if (r.HasRows)
{
r.Read();
txtIvestorName.Text = r.GetString("accountname");
txtRMemberId.Text = r.GetString("refererid");
txtRAmount.Text = r.GetString("investment");
txtTableNo.Text = r.GetString("tableno");
dtpClosingDate.Value = r.GetDateTime("dateofexpiry");
FillHistory();
}
else
{
txtIvestorName.Text = "";
txtRMemberId.Text = "";
txtRAmount.Text = "";
txtLateFee.Text = "0";
txtTableNo.Text = "";
dtpClosingDate.Value = DateTime.Now;
dgInvestorHistory.DataSource = null;
}
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
txtIvestorName.Text = "";
txtRMemberId.Text = "";
txtRAmount.Text = "";
txtLateFee.Text = "0";
txtTableNo.Text = "";
dtpClosingDate.Value = DateTime.Now;
}
if (cmbPlan.Text == "PS")
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "SELECT customerid, agreementdate, accountname, refererid, tableno, dateofexpiry FROM investers_ps WHERE investeridps LIKE '" + txtCustomerId.Text.Trim() + "' AND plan LIKE '" + cmbPlan.Text + "' ";
if (radCE.Checked == true)
{
qry += "AND ceid=" + txtMemberID.Text.Substring(5);
}
else
{
qry += "AND refererid=" + txtMemberID.Text.Substring(5);
}
MySqlCommand cmd = new MySqlCommand(qry, con);
MySqlDataReader r = cmd.ExecuteReader();
if (r.HasRows)
{
r.Read();
txtIvestorName.Text = r.GetString("accountname");
txtRMemberId.Text = r.GetString("refererid");
txtRAmount.Text = r.GetString("investment");
txtTableNo.Text = r.GetString("tableno");
dtpClosingDate.Value = r.GetDateTime("dateofexpiry");
FillHistory();
}
else
{
txtIvestorName.Text = "";
txtRMemberId.Text = "";
txtRAmount.Text = "";
txtLateFee.Text = "0";
txtTableNo.Text = "";
dtpClosingDate.Value = DateTime.Now;
dgInvestorHistory.DataSource = null;
}
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
txtIvestorName.Text = "";
txtRMemberId.Text = "";
txtRAmount.Text = "";
txtLateFee.Text = "0";
txtTableNo.Text = "";
dtpClosingDate.Value = DateTime.Now;
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnAddReciept_Click(object sender, EventArgs e)
{
if (cmbPlan.Text == "SID")
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "INSERT INTO reciepts_sid (recieptdate,customerid,statementid,amount,latefee,createdat,createdby) VALUES('" + dtpStatementDate.Value.ToString("yyyy-MM-dd") + "'," + txtCustomerId.Text.Trim() + "," + lblStatementNo.Text.Split('/')[1] + "," + txtRAmount.Text.Trim() + "," + txtLateFee.Text.Trim() + ",NOW()," + GlobalVariables.CurrentUserId.ToString() + ")";
MySqlCommand cmd = new MySqlCommand(qry, con);
cmd.ExecuteNonQuery();
TotalRecieptAmount += Convert.ToDouble(txtRAmount.Text.Trim());
FillHistory();
MessageBox.Show("Reciept has been added to [" + txtCustomerId.Text.Trim() + "] successfuly!", "Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtTotalAmount.Text = TotalRecieptAmount.ToString();
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
FillHistory();
}
else if (cmbPlan.Text == "RUC")
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "INSERT INTO reciepts_ruc (recieptdate,customerid,statementid,amount,latefee,createdat,createdby) VALUES('" + dtpStatementDate.Value.ToString("yyyy-MM-dd") + "'," + txtCustomerId.Text.Trim() + "," + lblStatementNo.Text.Split('/')[1] + "," + txtRAmount.Text.Trim() + "," + txtLateFee.Text.Trim() + ",NOW()," + GlobalVariables.CurrentUserId.ToString() + ")";
MySqlCommand cmd = new MySqlCommand(qry, con);
cmd.ExecuteNonQuery();
TotalRecieptAmount += Convert.ToDouble(txtRAmount.Text.Trim());
FillHistory();
MessageBox.Show("Reciept has been added to [" + txtCustomerId.Text.Trim() + "] successfuly!", "Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtTotalAmount.Text = TotalRecieptAmount.ToString();
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
FillHistory();
}
if (cmbPlan.Text == "PS")
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "INSERT INTO reciepts_ps (recieptdate,customerid,statementid,amount,latefee,createdat,createdby) VALUES('" + dtpStatementDate.Value.ToString("yyyy-MM-dd") + "'," + txtCustomerId.Text.Trim() + "," + lblStatementNo.Text.Split('/')[1] + "," + txtRAmount.Text.Trim() + "," + txtLateFee.Text.Trim() + ",NOW()," + GlobalVariables.CurrentUserId.ToString() + ")";
MySqlCommand cmd = new MySqlCommand(qry, con);
cmd.ExecuteNonQuery();
TotalRecieptAmount += Convert.ToDouble(txtRAmount.Text.Trim());
FillHistory();
MessageBox.Show("Reciept has been added to [" + txtCustomerId.Text.Trim() + "] successfuly!", "Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtTotalAmount.Text = TotalRecieptAmount.ToString();
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
FillHistory();
}
}
private void FillHistory()
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string qry = "SELECT recieptid,recieptdate AS `Date`,amount AS `Amount Paid`, latefee AS `Late Fee(if any)` FROM reciepts WHERE investorid=" + txtCustomerId.Text.Trim();
MySqlDataAdapter adap = new MySqlDataAdapter();
adap.SelectCommand = new MySqlCommand(qry, con);
DataTable tbl = new DataTable();
adap.Fill(tbl);
BindingSource bs = new BindingSource();
bs.DataSource = tbl;
dgInvestorHistory.DataSource = bs;
dgInvestorHistory.Columns[0].Visible = true;
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnSaveStatement_Click(object sender, EventArgs e)
{
try
{
using (MySqlConnection con = new MySqlConnection(GlobalVariables.ConnectionString))
{
con.Open();
string statementType = "1";
if (radNewBusiness.Checked)
{
statementType = "1";
}
else
{
statementType = "2";
}
string member = "";
string ce = "";
if (radMember.Checked)
{
ce = (0).ToString();
member = txtMemberID.Text.Substring(5);
}
else
{
member = (0).ToString();
ce = txtMemberID.Text.Substring(5);
}
string qry = "INSERT INTO business_statements (statementid,statementno,date,branch,memberid,ceid,noofenrollments,totalamount,statementtype,planname,createdat,createdby) VALUES(" + statementid.ToString() + ",'" + lblStatementNo.Text + "','" + dtpStatementDate.Value.ToString("yyyy-MM-dd") + "'," + BranchId.ToString() + "," + member + ",'" + ce + "',0," + txtTotalAmount.Text.Trim() + "," + statementType + ",'" + cmbPlan.Text + "',NOW()," + GlobalVariables.CurrentUserId.ToString() + ")";
MySqlCommand cmd = new MySqlCommand(qry, con);
cmd.ExecuteNonQuery();
MessageBox.Show("Business Statement[" + lblStatementNo.Text + "] has been successfully Created for Marketer:[" + txtMemberName.Text + "]!", "Created!", MessageBoxButtons.OK, MessageBoxIcon.Information);
dtpStatementDate.Value = DateTime.Now;
txtTotalAmount.Text = "";
txtDesignation.Text = "";
txtMemberID.Text = "";
txtMemberName.Text = "";
}
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
grpInvestors.Visible = false;
dgInvestorHistory.DataSource = null;
this.Close();
}
}
}
|
|
|
|
|
First, you don't call "values", so we have no idea what you're trying to do.
Second, you only post the RELEVENT code snippets, not your entire frickin' project. I'm not in the mood to read that massive amount of code.
|
|
|
|
|
Dave Kreskowiak wrote: post the RELEVENT code snippets, not your entire frickin' project. I'm not in the mood to read that massive amount of code
I second that, as I'm never in the mood to read the irrelevant code.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Pick one place to post a question and stick with it.
|
|
|
|
|
|
S. Karthik - Hosur wrote: how to call the values from the databases
"Attribute values" or "Tupel values" would do. What's up with the code that you posted?
Bastard Programmer from Hell
|
|
|
|
|
Hi, anyone knows a .NET component/library that can provide me certain informations about media files:
For video I would need :
- codec name
- Image size (resolution)
- duration
- format
- frame rate
- aspect ratio
- bit rate
Audio :
- duration
- codec name
- sampling rate
- channel no
- bit rate
Thank you in advance!
|
|
|
|
|
Actually im getting error when the below code is executed from unit test project...
where import is an xml file in the below code..
XmlTextReader importReader= new XmlTextReader(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Importcontent/import"));
the above code is present in one of the methods in different project(class library) which is used in test method in the unit test project
where as the above path is present in web project.
and the value of the
System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Importcontent/import")
is null..ie unable to get the complete path of the file i guess bcos the hostingenvironment is not running(web project)
The above code is working fine when running from the webproject ie it returns the exact path.
whereas returning null value when running from test project.
please let me know how to fetch the file path(where file is present in web project) when running from test project.
|
|
|
|
|
You shouldn't be trying to read files out of your live project in the unit tests. That's, well, not a unit test
|
|
|
|
|
Hi,
if you have a file to read in Unit test then you need your file in OUT folder. You need to add those files as DeploymentItem list(.testsettings file >> deployment submenu). you can add Deployment item from testsetting file or by adding class decoration.
like,
[DeploymentItem("Content/Importcontent/import")]
after doing one of the above procedure, you can access your file. one more important note : make sure your file property "Copy To Output directory" = Copy Always
Thanks
-Amit
|
|
|
|
|
How to get the all unauthorized installed applications in my pc using c#.
|
|
|
|
|
Don't post this everywhere - you have already posted it in QA, so the scattergun approach is not going to endear you to anyone.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Sorry...,Actually i need help on this question.
|
|
|
|
|