I think I'm just after advice on best practice with this! I have a database which has 2 tables. The first table has ID, Name, Address and the second table has ID and JobType. Table 02 can list multiple types of JobType so we could have
Table01:
1. D Smith. Address01
2. S.Jones. Address02
Table02
1. Accounts
1. Sales Ledger
1. Chartered Accountant
2. IT
2. Web Design
2. Graphic Design
2. 1st line support
A join gets them together and all works perfectly.However, the content will be updated when some one fills in a web form. Do get the form to send results to both tables, I assume I have to open the database twice or can I open it once and open each table one at a time? I know I could practice this and not ask the question but I am interested to know what is the most efficient way. I would also need to know what ID to use. So when I populate Table02 it uses the correct ID from Table01. At the moment Table01 ID field is incremented automatically. Would you suggest I always assign the ID myself, or would I need to query the database, find out what ID number is currently in use and then increment it by 1 and assign the new number to an ID variable which then populates the Table's Field? In which case, am I opening the database again or trying to perform all 2/3 stages in one go?
I working on website and i have ready database from the company database. I have a table Location has only two fields : city andtate.I tried to get select the * city where state = something , but i think it is wrong,Is it a Many-to-Many realtionship
I have my membership provider configured and working on my web host.
IŽd like to create a table, for example, table ARTICLES, and iŽd like that the user logged in, his ID or his NAME, was inserted into my ARTICLES database.Which one is the best table i could get for doing that ?
I was checking the table aspnet_users, but its Primary Key has a uniqueidentifer type.This wonŽt be a problem in the future ?Or is there a better way to relate my table with the membership provider ? Maybe another table OR another field.
I've just taken over looking after a website and well to be honest the way it's been put together is not the best, but I have to make do as the client does not have the money to make major changes.Anyway currently there is data stored in a MsSQL database and some in an XML file. The xml file does have a ContentID attribute which matches the ContentID in a table.Not really done much with XML as I tend to use a database and LINQ.What would be the best way to tie these two together so I could output the results in a gridview for example.
I tried to establish a relation between two tables in such a way that Table_Contracts will still accept NULL values for [PO_No], but [PO_No] on TableContract will be automatically updated when [PO_No] on Table2_PONo changed. Moreover, if you want to delete a record on Table2_PONo, it needs to be stopped if there is a related data in Table_Contracts.
I set a relation with these parameters:
Check existing data on creation or re-enabling> No
Enforce for replication> No
Enforce foreign key constraint> No
Delete Rule> No Action
Update Rule> Cascade
I got this error
Introducing FOREIGN KEY constraint 'FK_Table_Contracts_Table2_PONo' on table 'Table_Contracts' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
I have a table that is not getting updated. My insert command is working fine. Here is the update code from business logic area and stored prodecure. The SP works fine when I execute it from sql mgmt studio and updates the table:
My site extracts data from a MS SQL db and then connects to a mySql db which it writes the data to. My site is working properly when connecting to a db in cPanel at a remote website.
However, I have a mysql db also hosted on my site, and I'm connecting to it ok, but the loop is failing. There are 2 tables, one stores the category, and the other stores link data.
For each category
write to the category table for each link in this category write to the link table next next
The tables are being created, and the very first category is written to the table, but then nothing gets written to the link table.
How can I make this generate an error message? My webhost doesn't know what to do about it and they just want to see an error message.
I tried this once already, and neither of my lines worked:
I don't understand how the stored procedure is returning false. It's supposed to continue looping and continue writing rows. Right now it writes the very first row, and then it goes into the If Not AdvanceLinkBanned.Add(banrec) Then and it goes in here, prints the message and exits the sub. Why is it thinking the add returns false? If Not AdvanceLinkBanned.Add(banrec) ? Doesn't this return the id of the new record? Isn't this not zero? Zero would make it false. How can this be false? Isn't it supposed to return the next record created ? Doesn't SELECT SCOPE_IDENTITY() return the value of the record id? How do I test this?
I'm trying to update one my my tables from a field in another table.
I have Address fields on both tables and the old table has some addresses I need to copy over (I dont want to copy/paste or type them all in obviously). I basically need to:
I have a confusing question, I have a user table and it stores all the usual data for a user that you would expect but im trying to figure out how a user could add another user?
Sounds strange but each user in the User table has his own UI which is UserID how could I add another table where UserID can have a relationship with another UserID?
i.e how would I right the syntax for the above question if I wanted to display all the UserIDs friends on a page. How would I add a friend.
I have two tables and I want to display the second one based on the primary key:
the first table is tbl1 (id,fName,lName), and the second one is scnds(id,course,tbl1id).
I am practice using MVC 2.0, so I bulilt the the class repository
[Code]....
Then created the Studentcontroller
[Code]....
The problem is if I used Details method it will show only the first record, but I want to display every course that specific a student has. I don't know if the problem in repository or in the controller.
I have 3 tables (ShoppingCart, Data, Temporary) in database (Entities) I have no problems in getting data into ShoppingCart. I also know how to transfer data from columns in table ShoppingCart into columns of table Temporary (like EngName, CartID, Date, Quantity etc. - see code below) But I do not know how to multiply Quantity in table ShoppingCart by Price stored in table Data and save it into table Temporary. I think the problem is that I do not know, how to select coressponding row in table Data (see "var myCart2" in my code below) which holds the Price value for EngName previously selected by ("var myCart" also visible in the code). protected void Submit(object sender, EventArgse)
{ using (Entities db = new Entities()) { try { String cartId = GetShoppingCartId(); var myCart = (from cc in db.ShoppingCart where cc.CartID == cartId select cc); foreach (ShoppingCart item in myCart) { int i = 0; if (i < 1) { string engname = item.EngName; var myCart2 = (from c in db.Data where c.EngName == engname select c); Temporary ta = new Temporary(); Data d = new Data();
I am doing a data warehouse project.I have two tables tblA (id, type) and tblB(city, no_crimes, type).I want to create (insert) a number of rows based on the value of no_crimes.For Example, in tblB(Leeds, 2000, murder). SO, I need to insert 2000 rows into tblA by a single INSERT statement (not 2000 statements).
How can I design an efficient AJAX based dynamic table using .NET ? Do I necessarily need to use JQuery / Prototype libraries or plug-ins to achieve this?I am referring to similar implementation : www.coupontom.com
I believe this is not possible using the existing AJAX control toolkit.
So I have an <asp:Gridview> and in my C# file, I am setting the datasource to some database table, and doing .DataBind().
However, I want to hide a column in the table based on a Boolean variable.
Something like this:
gridview.Columns['Field5'].Visible = false;
Or perhaps:
int c = gridview.Rows.Count(); for(int i = 0; i < c; i++){ gridview.Rows['Field5'].Remove(); }
Perhaps I cannot make it invisible, but I'm sure I can at least loop through and remove all rows related to the column "field5". I don't know how to go about doing this.
Does anyone perhaps have a proper link to using the GridView Class and how all the methods are suppose to be used because it's not clear, perhaps not written by microsoft?
the internet seems to lack a lot of C# documentation (or maybe it's just cluttered with too much useless ASP.net information).
I have a TextBox entry field where the user will enter a integer value. And then there is a "Create" button, which when clicked upon must generate a Table with 2 columns :
"Name" and "Email" being the column headers.
I want each row to have a textbox in each of these columns.
All of this has to happen after the button is clicked. I have discovered that if you dynamically add a control in ASP.NET(I am using C#) then the controls are lost during postback. And I don't know how to prevent that from happening.
Can somebody give me some ideas regarding how to go about adding rows dynamically to a table (I tried using the asp.net Server side table control but ran into the "lost-during-postback" problem - can I try with something else like a gridview ? but afaik a GV will not work without data bound to it )
Point to note is that my table has textboxes for user entry and it is not for showing data ..rather it is for accepting data from the user which will be later used to persist details to the database.
There are more columns in that grid, but I've slimmed it down just for the question.
Now, what I would like to do is change the tr's background color based on the price amount. If it is within different levels, I would like to change the rows background color correspondingly.
Do I have to do this with javascript or is there some way I can get access to the table rows in the code-behind to set this color?
I have a requirement that I have to retrieve data base on month and year.I am using the below query
<pre lang="sql">SELECT SUM(areasft),DATEPART(year, sdate),DATEPART(month, sdate) FROM storedata GROUP BY DATEPART(year, sdate) ,DATEPART(month, sdate) ORDER BY DATEPART(year, sDate) ,DATEPART(month, sDate)</pre>
ItemNo refno Process Name Qty 001 1 A John 50 001 2 A Jon 150 002 3 B Kalis 100 003 4 A Bob 300 Second Table ItemNo Newrefno Process Name Qty 001 001 ZZ peter 50 001 001/a ZkZ Joe 70 002 002 Ab Ray 100 Result Set 001 A John 200 001/a ZZ ZkZ peter joe 50 70 002 B Kalis 100 002 Ab Null Ray Null 100 Null 003 A Bob 300 null null null null null null null
Here first row of the result set explanation:
up to this 001 A John 200 based on first table sum...
and 001/a zz ZkZ peter joe 50 70
here 001/a newrefno of 001 so i need to show all the ItemNo 001 record in one row like the above resultset.
I have 2 Tables , OrderDetails and Requests In my LINQ to SQL dbml file. OrderDetailsID is a foreign key in Requests Table. I want to write the query to get the sum of UnitCost from OrderDetails based on OrderId. And If there is a row in Requests Table for each OrderDetailsID, and the Requests.Last.RequestType="Refund" I want to reduce the total refund amount from the main sum otherwise If there is no row based on OrderDetailsID, add to sum. Here is the way I implement that. I am looking to prevent using "For each".
iRefund = (From od1 In dc.OrderDetails _ Where od1.OrderID =1 _ Select od1.UnitCost).Sum Dim objOrderDetails = (From od1 In dc.OrderDetails _ Where od1.OrderID =1 _ Select od1) For Each OrderDetail As ORM.Entities.OrderDetail In objOrderDetails If Not OrderDetail.Requests Is Nothing Then IF OrderDetail.Requests.Last.RequestType="Refund" Then iRefund -= OrderDetail.UnitCost End If End If Next
i have this table and want to change the background-color to be yellow if the server used int he SQL connection string is not 'pheddv20'i am adding c# code to the page load event to check for this and run the dynamic logic. the connection string is held in the web.config as is typically seen...whats the code look like for this type of action?
I have a database table containing scripts for plays/dramas. The scripts can be categorized under 'Theatre and Education', 'Plays for Young People' or both (by using bools to determine whether they belong to said categories);
scriptID: int theatreAndEducation:bit playsForYoungPeople: bit[code]....