i have a website that needs to retrive some records in the database, to be specific, example is their Email Address, its more or less 10 records out of 100 records in a table but that number changes from time to time. upon retriving their Email Address, i need to Email them some messages one email at a time.
So to summarized it all:
1. Retrive data from a table (Email Address)
2. Make a Loop on each Email then send Message one email at a time.
give me a sample codes for the retriving and looping process?
Not sure why this is messing with my brain so much today, but I have a SQLDataReader that loops through "Customer" records. In each loop there are MANY other conditions that need to be validated. When a condition fails I want it to move on to the next record in the reader. As you see from my code below, I have simply been exiting the for loop and then checking if I should run other loops all the way down. I want to simply move back to the top of the While Loop for another pass when something like this happens:
I am dealing with dynamic fields in a for loop and now I need to retrieve the values that are being typed in the dynamic fields, any idea how can I do that? 2)also when I click the submit button, upon postback, the dynamic fields have gone missing, have been trying to slove that, but i did not, anyone knows how to deal with this? kinda urgent :x
3) and How do you compare the 2 dynamic fields? For eg: Im comparing the tbSch[i] to tbSch[i], so that the dates cannot be the same, am using a compare validator, but it throws me error that im comparing the same fields :) even though i change to ("tbSch" + i) for both, sorry Will provide my code snippet as follow :D tbNum is a textbox where user enter numbers and click generate
protected void btnGen_Click(object sender, EventArgs e) { for (int i = 0; i < Convert.ToInt32(tbNum.Text); i++) { // label and textbox needed Label lblSch = new Label(); TextBox tbSch = new TextBox(); Label lblWsGrp = new Label(); DropDownList ddlWsGrp = new DropDownList(); CompareValidator cvSame = new CompareValidator(); cvSame.ID = "cvSame" + i; cvSame.ErrorMessage = "Date cannot be the same"; cvSame.Operator = ValidationCompareOperator.NotEqual; cvSame.Type = ValidationDataType.Date; cvSame.Display = ValidatorDisplay.Dynamic; cvSame.EnableViewState = true; cvSame.ControlToValidate = (tbSch.ID);<<<<< what should be the value in here? cvSame.ControlToCompare = (tbSch.ID);<<<<<<<<<< and here? //schdule date lblSch.ID = "lblSch" + i; lblSch.Text = "Session Date : "; lblSch.EnableViewState = true; tbSch.ID = "tbSch" + i; tbSch.Width = 210; tbSch.Height = 27; tbSch.EnableViewState = true; //workshop grp lblWsGrp.ID = "lblwsgrp" + i; lblWsGrp.Text = "Workshop Group : "; lblWsGrp.EnableViewState = true; ddlWsGrp.ID = "ddlWsGrp" + i; ddlWsGrp.Height = 27; ddlWsGrp.Width = 210; ddlWsGrp.EnableViewState = true; ddlWsGrp.Items.Add("1"); ddlWsGrp.Items.Add("2"); //table to store data TableRow trow = new TableRow(); TableRow trow2 = new TableRow(); //row1 TableCell tc1 = new TableCell(); TableCell tc2 = new TableCell(); TableCell tc3 = new TableCell(); TableCell tc4 = new TableCell(); //row2 TableCell tc5 = new TableCell(); TableCell tc6 = new TableCell(); TableCell tc7 = new TableCell(); TableCell tc8 = new TableCell(); TableCelltc9 = new TableCell(); tc1.Controls.Add(lblSch); tc2.Controls.Add(tbSch); tc3.Controls.Add(lblWsGrp); tc4.Controls.Add(ddlWsGrp); tc5.Controls.Add(space); tc6.Controls.Add(CeSess); tc7.Controls.Add(space); tc8.Controls.Add(space); tc9.Controls.Add(cvSame) trow.Cells.Add(tc1); trow.Cells.Add(tc2); trow.Cells.Add(tc3); trow.Cells.Add(tc4); trow2.Cells.Add(tc5); trow2.Cells.Add(tc6); trow2.Cells.Add(tc7); trow2.Cells.Add(tc8); trow2.Cells.Add(t9); this.table3.Rows.Add(trow); this.table3.Rows.Add(trow2); } }
I am currently looping through all the controls on my page and setting certain types (TextBox, CheckBox, DropDownList, etc.) to Enabled=False under certain conditions. However I notice an obvious page load increase looping like this. Is it possible to only get certain types of controls from the Page.Controls object rather than Loop through them all? Possibly with something like LINQ?
to loop through each field in a record to test for a value and then set a flag at the end of each record if an instance of this value occurs in any fields?I have a table where some fields values are have a *c* at the beginning of the text eg "*c* value" . What I would like to do is run a select query off the table and at the end of each record have a field called "Change Flag" and a value of "Changed" or "No Change" depending if a *c* has been encountered.
There are a number of tables to run this against all with differening numbers of fields/
I have a small form of 4 fields, I am using Ajax to save record and give alert to user on same page. all is working fine but I want to clear all 4 fields after record is inserted and don't want user to press again and duplicate,
Right now I am using
this._studentName.text = "";
but is there any easy method to get same result coz I have another form where there are more then 40 fields and don't want write .text = "" 40 times
basically, the InstellingGegevens table gest filled in by some procedure from another server. the thing i then need to do is check if there are new records in this table, and fill in the new ones in Instellingens.
this code runs for like 4 minutes on 15k records. how do I optimize it? or is the only way a Stored Procedure?
this code runs in a timer, running every 6h. IF a stored procedure is best, how to I use that in a timer?
I've got a gridview with three fields, the last of which is a template field with an imagebutton in.
The first field is a Date, and the second is a time field (it is however just varchar field as it may differ and will not be programmatically used).
I want the following to happen if I click on the imagebutton (reserve):
Four other fields must be inserted into the record.
Is the best way to launch a detailsview where the row.imagebutton@=ID and just edit the fields like that or should I pass the two fields (and RecordID) along with the query string to a new page where the passed information can be in invisble textbowes and just have the user enter (UPDATE) the four outstanding fields? I feel like doing it this way?
can read on 1. setting up the onrowcommand code for the templatefield 2.
This should be simple as it is only one table with records that has to be partially inserted by an admin person (2 Fields) and then completed by a web user (4 fields).
My project includes a grid view which displays information of inventory items (Assets), data is quried from AssetTable. The GridView has a command field to allow editing, below is a description of the tables and how data is displayed
Tables BuildingTable: (BuildingID, BuildingName) AssetTable: (BuildingID,..,....,....) ItemTemplate: Using a LINQ query I join the two table and displays in a label control a string which includes BuildingID and BuildingName (5 North Building)
I have Two fileds the names are QtyRec and QtyReq in my table when These two are identical(10=10) then corresponding recrod should not listed in Gridview. Can any one provide solution
Gridview Code is Public Sub retriveDataToDataGrid() Try Dim connectionString As String = "Database=pjt;" & "Data Source=localhost;" & "User Id=root;Password=prasad123" Dim query As String = "Select WONumber,paertno,mfgpart,manufacturer,QtyRec,QtyReq,QtyShort,Duedate,Notes from ilist order by WOnumber" Dim connection As New MySqlConnection(connectionString) Dim da As New MySqlDataAdapter(query, connection) Dim ds As New DataSet() If da.Fill(ds) Then GVIL.DataSource = ds.Tables(0) GVIL.DataBind() End If connection.Close() Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub
I use Visual Studio 2010 and MS SQL Express edition. .NET 4.0
Database model is very simple. I have articles and each articles has a category. Simple relationship 1 category many articles.
So to take all articles I use code:
[Code]....
and it's automatically loads Category reference and all Category references to. So it's looks like it's load all nested fields automatically. How I can deny this?
I was thinking that I should use .Include("Category"), but it seems that it's don't needed.Problem is that when I try to send it it's throw an exception:
The maximum read depth (32) has been exceeded because XML data being read has more levels of nesting than is allowed by the quota.
I am working on an application and am attempting to use Linq with and ObjectDataSource but I only want to display/update 50% of the fields that are in the corresponding table. It appears to me that for this to work correctly, I need hidden fields on my form for all of the data fields from the table that the user cannot access. Is this the only way to do this? I have the following in my update method of my ODS:
[Code]....
The problem is, only the fields that appear on the form have data in them.
How to make the linq throw error, when not null columns are there in the table.
Why I am saying, it is. I tried to add to column in the table. Linq throwed error os some sort. I could not understand. it was like some innner table etc.
I had to resort to native sql, which showed the error, as the not null fields are there in the table.
I'm inserting data into a database with Linq to SQL and would like to access the primary key of that record WITHOUT doing a query for the values I've already captured.
Here is my insert startment:
[Code]....
There is a value in the table that is an auto increment integer.
Rather than doing a query for the pagetitle, description and content I'd like to just access the primary key that I would have just generated by performing the insert.
Is this possible or would I have to perform the query as I've just mentioned to retrieve it?
If I have an ID, I would like to retrieve the next item that also has the same category as the item ID I have. So, for example, if I have ID=2, I would like to return the item with ID=4 (as item ID=3 has a different category).
I would assume this is possiable but I cannot seem to find it anywhere. I just one the contents of a single field, I don't see why I have to return the how
record to get get that information, here is my current code, how can I make this better without returning the entire record, for just getting contents of one field.