hi i have a database i created it by sql server 2012.i wanna use this in c# 2012 by LINQ but i dont know how i should use it in my application.i want all source code about LINQ for joining to that database.
for example i have a store procedure in my database i wanna know how can i use from this store procedure by linq in c#.or i have views in my database how should i use from these view by linq in c# 2012.please help me.
I am trying to page my results. However, my Next Link and my Last Link always bring up my first page. I cannot get to the second page of results.
Might anyone have any idea as to what I am doing wrong?
publicpartialclass _Default : System.Web.UI.Page
#region Web Form Designer generated code
protected System.Web.UI.WebControls.RadioButton rdoProduct;
protected System.Web.UI.WebControls.Image Image1;
///<summary>/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
this.cmdSearch.Click += new System.EventHandler(this.cmdSearch_Click);
this.Load += new System.EventHandler(this.Page_Load);
#endregion#region"Local Variables and Declarations"privateconstbool blnAllowPaging = true;
privateconstint iPageSize = 5;
PagedDataSource pgdProducts = new PagedDataSource();
protectedvoid Page_Load(object sender, EventArgs e)
//Hide results controls
rptClasses.Visible = false;
lblMessage.Text = "";
//set previous link, next link and page# labels to invisible.
lblCurrentPage.Visible = true;
lnkNext.Visible = true;
lnkPrevious.Visible = true;
//Populate within values (real app would pull from DB)
cboWithin.Items.Add("Only this zip");
cboWithin.Items[cboWithin.Items.Count - 1].Value = "0";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "5";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "10";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "25";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "50";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "100";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "200";
cboWithin.Items[cboWithin.Items.Count - 1].Value = "999";
#endregion#region"Footer LinkButtons"protectedvoid lnkFirst_Click(object sender, EventArgs e)
//Set viewstatevariable to the next page.
NowViewing = 0;
protectedvoid lnkPrev_Click(object sender, EventArgs e)
//Set viewstatevariable to the next page.
//CurrentPage -= 1;
protectedvoid lnkNext_Click(object sender, EventArgs e)
//Set viewstatevariable to the next page
//CurrentPage += 1;
protectedvoid lnkLast_Click(object sender, EventArgs e)
//Set viewstatevariable to the previous page
NowViewing = pgdProducts.PageCount - 1;
#endregion#region"Footer DropDownList"protectedvoid ddlpageNumbers_SelectedIndexChanged(object sender, EventArgs e)
//pgdProducts.PageSize = int.Parse(ddlpageNumbers.SelectedValue);
NowViewing = ddlpageNumbers.SelectedIndex;
#endregion#region"Custom Functions"privatevoid BindRepeater()
pgdProducts.AllowPaging = blnAllowPaging;
pgdProducts.PageSize = iPageSize;
pgdProducts.DataSource = GetProductsDataView();
pgdProducts.CurrentPageIndex = NowViewing;
//lblTotalPages.Text = pgdProducts.PageCount.ToString();
//tell what page number the user is on and how many pages of results there are total.
//lblCurrentPageBottom.Text = "Showing Page " + CurPage.ToString() + " of " + pagesCount + " ";
lblCurrentPage.Text = "Now Showing Page " + (NowViewing + 1).ToString() + " of " + pgdProducts.PageCount.ToString();
lblItemsPerPage.Text = (pgdProducts.Count).ToString() + " items per page.";
//lblTotalItemCount.Text = (objPds.Count * objPds.PageCount).ToString() + " total number of items that your search returned.";
lblTotalItemCount.Text = (pgdProducts.DataSourceCount).ToString() + " total number of items that your search returned.";
lnkFirst.Enabled = !pgdProducts.IsFirstPage;
lnkPrevious.Enabled = !pgdProducts.IsFirstPage;
lnkNext.Enabled = !pgdProducts.IsLastPage;
lnkLast.Enabled = !pgdProducts.IsLastPage;
ddlpageNumbers.SelectedIndex = pgdProducts.CurrentPageIndex;
rptClasses.DataSource = pgdProducts;
private DataView GetProductsDataView()
DataTable dtProductsTemp = new DataTable();
using (SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]))
using (SqlDataAdapter adapProducts = new SqlDataAdapter("cmd", conn))
SqlParameter arParms = new SqlParameter;
arParms = new SqlParameter("@Zipcode", SqlDbType.Char);
arParms.Value = txtZipCode.Text;
arParms = new SqlParameter("@Miles", SqlDbType.Decimal);
arParms.Value = Int16.Parse(cboWithin.SelectedItem.Value);
arParms = new SqlParameter("@Subject", SqlDbType.Char);
arParms.Value = txtSearchWords.Text;
DataSet ds = new DataSet();
ds = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["ClassesnWorkshops.Properties.Settings.ConnectionString"].ConnectionString,
CommandType.StoredProcedure, "spHouses_GetNearZipcode", arParms);
dtProductsTemp = ds.Tables;
privatevoid FillPagesDropDownList(int iTotalPages)
for (int i = 1; i <= iTotalPages; i++)
ddlpageNumbers.Items.Add(new ListItem(i.ToString(), i.ToString()));
object obj = ViewState["_NowViewing"];
if (obj == null)
this.ViewState["_NowViewing"] = value;
//this.thisPageNumber = value;
protectedvoid cmdSearch_Click(object sender, EventArgs e)
DataTable objDT = null;
//Query the database for classes
objDT = GetProductsDataView().ToTable();
//Any classes found?
if (objDT.Rows.Count == 0)
//None found - hide repeater, show message
rptClasses.Visible = false;
lblMessage.Text = "No results found";
// //Houses found - show repeater, hide message
rptClasses.Visible = true;
lblMessage.Text = "";
catch (Exception ex)
//Add your own error handling here
lblMessage.Text = "Error: " + ex.ToString();
objDT = null;
I've got it!
It was not so much a code issue, as a VisualStudio.Net issue. I hard coded the Click Event for the lnkNext. For some reason, VisualStudio was ignoring this code, so my Next Link was doing nothing (thus the first page was returned again).
I needed to double click the linkButton control so that Visual Studio automatically created the Click Event for the control. Now it recognizes what the Next Link is supposed to do and gives me page 2!
fraud checking is done using checksums and the like
What a simplistic idea! Just think of a freshly stolen credit card which has not yet been reported stolen. Or a "copied" credit card, or some hacker using the credit card number for purchases in the web... Here you'll need some highly sophisticated heuristics.
I think you meant "artificial intelligence" systems and not "artificial immune" systems.
As has already been mentioned, this is a wide subject and cannot be explained a reply to your post. I suggest you begin by reading some of the papers and books mentioned in the Reference section on this[^] page.
Depends on a huge number of factors: primarily the physical size of the label you are going to print. If it's only one inch by 1/4 inch, that eliminates a lot of versions.
The link Richard gave you covers a lot of the variants: start there and do some research!
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
I have a C# and Silverlight project with two combo boxes (CB1, CB2)
-CB1 is initialized and populated with few items.
(e.g. car, plane, motorcycle)
-User selects an item (e.g. car) and CB2 gets automatically populated
(e.g. model, year, color) via the cb1_SelectionChanged()
-user selects the item from CB2 (e.g. model) and a datagid is populated accordingly.
Once I selected item from CB2 and datagrid is populated correctly, attempting toselect a different item from CB1 generates a “Object reference notsetto an instance of an object”
Togo around just select a different item then back again to the item and that woks but is really annoying. :)
Any ideas will be greatly appreciated
Comboboxes use to send two SelectionChanged events when the user changes the selection: in the first event, the previously selected item is un-selected, at this moment no item is selected, comboBox1.SelectedItem is null, and consequently comboBox1.SelectedItem.ToString(); causes a NullReferenceException.
Then the new item gets selected and SelectedItem has a value again.
Solution: check SelectedItem for null.
I understand you aren't going to be able to give me a specific answer, but I am kind of stunned at this point...
I work on a library that has competitors. Our APIs are pretty similar. I call MyLibrary.MethodA() 1,000,000 times. It takes 1000ms. I call MyCompetitor.MethodA() 1,000,000 times and it takes 150ms. Both in Debug / Any CPU.
I'm trying to figure out where my overhead is. So in MethodA() I tried returning just null at the beginning. That was already 16ms. MethodA calls an internal method which calls another one, etc. Basically, the only thing I'm doing at the top level methods is checking the params for null. Then I lock a dictionary and do a TryGetValue. At this point I start getting to the method that starts doing real work. I'm already at 195ms and am returning null.
How is that even possible? The other guy is returning 150ms and actually doing the work. I'm at 195ms and returning null from an empty method???
For other CPians to help and give you useful suggestions, you have to give more context what the method is doing and what algo it is using and does it access the network to access the DBMS? Does it use LINQ? Does it use reflection? Does it use C++/CLI interop? etc...
Yes, as I said, I haven't gotten to optimizing the algorithm itself yet .
Just calling EMPTY methods in my DLL is slower then calling the other guys FULL method. That's where I'm confused.
His FULL method is 150ms for 1,000,000x.
I'm just calling 4 pretty empty methods. Method1 does nothing but call Method2 (a generic method calling the non generic version). Method2 calls Method3 which just checks that the param is not null and then calls Method4. Method4 locks on a dictionary and calls TryGetValue() (Key = Type, Value = Info class). If it can't find the Info class in the dictionary, it news one up. Now it calls Method5. At this point, I haven't even done the work yet, just getting set up and I'm already at 111ms. The other guy is already done completely at 150ms. That's what I'm puzzled about. Haven't even gotten to any code that I can optimize yet .
He might be caching some data in memory - it could be slower when you call the method only once, but surely speeds up when the method is called a million times.
Are you sure that the competitor's method is thread-safe?
If I understand this correctly, you are calling you method 1 million times and it takes one second. So 1 microsecond to execute. That doesn't sound like a lot to me, but without knowing what it does who knows.
At such speeds, dictionary lookups start to become quite heavy duty operations. I would think locking the dictionary would start to have a bad impact as well (I've got the time 80ns in my head, but that's probably wrong).
Remember that for each look up, the dictionary might call GetHashCode() and Equals() on multiple objects so you need to make sure that your implementations of these things are very efficient.
Bin the dictionary and switch to non-locking synchronization if possible. Also, get Reflector or something on the competitors assembly and see what's happening.
Last Visit: 31-Dec-99 18:00 Last Update: 28-Aug-14 20:15