i have a form view that takes fields from two tables 'Contract' and 'volunteers', however because i used a query builder,i have to input an insert statement. How do i create an insert statement for two tables in one query?
I have a table that contains item data. If the item is a particular type further information exists to describe the item. The additional information isn't that heavy however the number of records in relation to the main file will be quite small (less than 5%).
So I have 2 scenarios:1) Put the additional data in the main table and take tha hit on storage
2) Create an additional table and link the 2 together
If we were talking huge amounts of data I can understand that 2) would be the obvious choice but given the simplicity should 1) be a consideration?
If 2) is the answer - is it possible to create a dependency between the 2 tables when the item is 'that' particular type. In other words wnsure the addition data is populated for the required items and not others.
I want to declare a variable in such a way that I can access that particular variable and its value in all the asp pages in the project. Can anyone tell me how to declare a variable in C# such that it has project-wide scope?
I am trying to create a method that accepts multiple types of controls - in this case Labels and Panels. The conversion does not work because IConvertible doesn't convert these Types.
public void LocationsLink<C>(C control) { if (control != null) { WebControl ctl = (WebControl)Convert.ChangeType(control, typeof(WebControl)); Literal txt = new Literal(); HyperLink lnk = new HyperLink(); txt.Text = "If you prefer a map to the nearest facility please "; lnk.Text = "click here"; lnk.NavigateUrl = "/content/Locations.aspx"; ctl.Controls.Add(txt); ctl.Controls.Add(lnk); } }
I need to populate a listbox programmatically from 1 of 2 tables, depending upon user inputs at run time and I need to know how many rows to read. Otherwise, I get an exception error when I try to read data that does not exist after all rows have been read.
I need to retrive a value from a column of a table per stored proc. This is usually an integer, but also can be null. I get this value and store it in a session variable.
Later, I need to pass this same session variable to another stored proc.
Session["myVariable"] = ds.tables[0].rows[0][1]; // this can be null or an integer
somewhere else in the project, I need to pass it to another stored proc exactly as received.
I get a recordset returned from DB and try to load it. However sometimes field "LastRun" may be empty (NULL). when i have this it compiles fine but errors out when value is null m_LastRun = Convert.ToDateTime(r["LastRun"]); when I take out Convert.ToDateTime it doesn't even compile.
i am trying to write a stored procedure which constructs an email containing a table. typically, when creating a string of HMTL code, i might have something like:
@strEmail = @strEmail + chkNum + '<br>'
but how do you handle it if the html needs single quotes?
Both the Method 1 and Method 2 can handle the paging of GridView, could you tell me how about the performance of the Method 1?and how much will Method 1 slower than Method 2
#region ForPaging public static List<HD_ToDoList> Get_ToDoListByUserNameForPage(string username, int StartIndex, int PageSize) {
I'm creating a site that will offer several different services (blogs, videos, images..), all under the same site.
Each service will use a separate database and all services must use the same membeship info. Users will only need one login to access all these services.
For the membership database i will use the default aspnetdb database.
There are two ways i can think of:
1) Use a join-query between two databases, each time i want to show some service records per user.
2) Create a custom membership-info table in each service's database, and keep it in sync with the master membership table in aspnetdb database.
string connectionstring = WebConfigurationManager.ConnectionStrings["AdventureWorks"].ConnectionString; SqlConnection con = new SqlConnection(connectionstring); DataSet ds = new DataSet(); DataRelation dr = new DataRelation("show", ds.Tables["HumanResources.Employee"].Columns["EmployeeID"], ds.Tables["HumanResources.EmployeeAddress"].Columns["EmployeeID"],false); ds.Relations.Add(dr); foreach (DataRow row1 in ds.Tables["HumanResources.Employee"].Rows) { Response.Write("customertitle:" + row1["Title"].ToString()); foreach (DataRow row2 in row1.GetChildRows(dr)) { Response.Write("customer add" + row2["ModifiedDate"].ToString()); } }
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error:
[Code]....
Line 31: Line 32: DataSet ds = new DataSet();Line 33: DataRelation dr = new DataRelation("show", ds.Tables["HumanResources.Employee"].Columns["EmployeeID"], ds.Tables["HumanResources.EmployeeAddress"].Columns["EmployeeID"],false);Line 34: //ds.Tables["HumanResources.Employee"].ParentRelations.Add(dr);Line 35: ds.Relations.Add(dr); Source File: d:databaseDataset showing selected field of 2 tables.aspx.cs Line: 33 Stack Trace:
[Code]....
[NullReferenceException: Object reference not set to an instance of an object.] dataset__with_two_tables.Page_Load(Object sender, EventArgs e) in d:databaseDataset showing selected field of 2 tables.aspx.cs:33 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
I have a Customer object that has two address ID fields (one for HomeAddress and one for WorkAddress)
I am loading the Address Objects by using Include="HomeAddress, WorkAddress" and then binding to the properties using the Navigation Property on the Customer Entity
Can I use just one FormView for doing the Insert/Updates and binding it to an EntityDataSource or would I have to do all the Inserting/Updating manually?
I currently have a gridview which I have populated using the following method:
[Code]....
What I am looking for is advice on how to handle coding a proper DeleteMethod to assign to my ObjectDataSource (via my class file). I have been searching through several forums, websites and other media and have been left a little confused. Everyone seems to have their own method, none of which I have been able to successfully adapt to my own needs. Here is some of the functionality that I am looking for:
1.) Delete item using Gridview's delete button
2.) Delete the record from both the datatable (and Gridview Row) and the database that the table was generated from.
3.) Upon deletion, refresh gridview
This may sound simple to many of you, but I need a little advice as to where to start. Any applicable threads, tutorials etc.
I have used a microsoft tool before that was allowing me to automatically generate admin web pages from database tables. By admin web pages I mean pages that allow me to do CRUD operations on my tables.
OK I'm a total noob so bear waith me. I'm using the pubs database. I want to add several gridviews to my page in the inside of a for loop. Here is my code so far:
[Code]....
In the foreach loop, it is iterating through the publisher's tables rows, and I wamt it to query the titles table to find all books that have that publisher id and create a gridview out of it. In the code above I am not getting it right. I need multiple GridViews, one for each iteration of the foreach loop. How do I do this?
What I don't quite get is why the total database size is 642.56 MB when the size of the individual tables is so much smaller. We pay for the total amount, in chunks of 500 MB. I was trying to see which tables where causing the DB to be so big, but to me, it looks like it is not the size of the tables but something else.
What should I look at to figure out why we are taking up so much space? Am I not understanding how this works?