SQL Server :: Inserting And Updating 2 Tables In 2008 From 2 Worksheets In Excel?
Oct 4, 2010
I have an excel sheet with 2 tabs and has data in those 2 sheets(sheet1, sheet2) which correspond to different tables in the same database. This excel sheet gets updated daily, I am wiriting a console app( which will later be a batch build). I have to insert the data from the excel sheet to corresponding tables (table1, table2,table3) in database when i run it and and also if the table has the same data already present it should ignore and if there are any modifications done the data it should update the table. I know we can do this using ado.net or LINQ, I am a little new to database based programming .
I have an C# ASP application I am writing that needs to have the capability to import a generated excel or a comma delineated sheet each day. A clerk will have this job each morning so it doesn't need to be automated. My problem in trying to understand the solution to this is that the 1 sheet contains loan information, including customer information all in the same sheet. I would like to send certain columns to update information in the loan table and send other information to update the customer table. I need it to create relationships when new loans appear in the spreadsheet.
Addresses: AddressID | Address1 | Address2 | City | State | Zipcode
I have a page where you can add a contact. It contains all the information for a contact and an address for a contact. Here's my code for when you submit the form:
[code]...
Now my main concern is that the address is added successfully, but then an error occurs when I try to save the contact, leaving the address in the database with no contact.
What's the best practice here for rolling back any changes if an error occurs?
I am binding data from a dataset to a grid and exporting data from the grid to an excel.if the the number of items in the grid is greater than 50000,an error message is displayed.
So i want to split the data and display it in different worksheets in excel.(Am working in a web application)
using this code for exporting to excel
gvExcel.DataSource = DTS; gvExcel.DataBind(); Response.AddHeader("content-disposition", "attachment; filename= filename.xls"); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gvExcel.RenderControl(htw); // Style is added dynamically Response.Write(style); Response.Write(sw.ToString()); Response.End();
I have an SQL DB which contains 2 tables. The first one 'advs' has some information about an advertisement and it got an ID field. The second one, "photos", contains all the paths of photos, this one also has an ID field.
Each advertisement from the 'advs' Table has three photos in the PHOTOS table. now obviously the photos related to the 'ad' must have the same ID.
What I'm trying to do is a Form to add the information about each advertisement and its' photos. This form should enter the SAME ID number to both tables AUTOMATICALLY after adding.
I have two tables master and comp table. In master table, I have columns called LB1, LB2, LB1_ID, LB2_ID and in my comp table I have ID and CompName. I need to update my master table the following way
If LB1 in master table has a value of 'XYZ' then I need to find that value in Comp Table in column compName and then put the ID from comp table to master table in LB1
master
LB1 LB2 LB1_ID LB2_ID XYZ HIJ ABC KLM DEF RAW PQR VQS
Comp
ID CompName 1 XYZ 2 ABC 3 RAW 4 DEF 5 VQS 6 HIJ 7 KLM 8 PQR
I need to poulate my master table like this
master
LB1 LB2 LB1_ID LB2_ID XYZ HIJ 1 6 ABC KLM 2 7 DEF RAW 4 3 PQR VQS 8 5
I m getting following error in my eventvwr . I couldnt find reasons of the following error.
"Transaction (Process ID 110) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction. "
The only thing my page is doing is inserting/updating data into a table in sql and the thing I can think of is because multiple users are using the same page to insert/update data? Will that cause deadlock?
I have excel file with columns EmpName,Date1,Date2,...Date7 .I want to insert EmpName into Employee table after inserting i will get EmpNo(Identity column) with that i need to insert Date1,Date2...Date7 into TimeSheet table.
My Excel structure is like this EmpName 8/1/2010 8/2/2010 8/3/2010 8/4/2010 8/5/2010 8/6/2010 8/7/2010 Naresh 17:00-2:00 17:00-2:00 14:00-12:00 7:00-12:00 7:00-12:00 .. Off Similarly 500 employees data
I want to insert name i.e into Emp table after inserting i will get EMpNo i.e identity column with that i should insert Date1(8/1/2010) i.e excel header to date7 into Timesheet table Date column and corresponding time into TimeIn and TimeOut.I will split the time.I just want write Stored procedure for this task.
My database tables are like this
Emp-EmpNo,EmpName,CompaignId Timesheet-TimeID,EMpNo,Date,TimeIn,TimeOut,TotalHours Date in Timesheet should be like this TimeId EmpNo Date TimeIn TimeOut T otalHours
1 100 8/1/2010 17:00 2:00 9hrs
2 100 8/2/2010 17:00 2:00 9 hrs
7
I just want this logic on how to insert Date1 to date 7 as 7 rows into Timesheet table and EMpName into EMployee table.while accesing each row i need to insert Date 1 to date7 as 7 rows into Timesheet table.
I am using reading data from excel file and inserting into sql server using following article, it seems to be working correctly except when I do page refresh normally, it again execute the the btnUpload_click. I want that once the record imported and if user refresh the page again it should ask for enter file name again. let me know how do I resolve this? [URL]
I have 3 dropdownlist with day,month(e.g Jan, Feb...) and year value. However I am getting an error from my code when trying to insert the concantenated values into a date field in sql server 2008.
how to connect the two tables of the sql server 2008 databse in C#.
in this there are two tables
1) Tour header(id, name, city, destination)
2) Tour Detail(id, tour id, day no, title,description,images)in this id of tour header and tour id of tour header will be same.now i want to retrieve the data on the basis of when id==tour id.how can we can run the query of two tables.
i have a store procedure that load data in a table of SQL SERVER 2008 from an excel file.the issue is, that the excel file have a column of DATE type, and i want that the system interprets the format in it, no matter what comes in it.dd/MM/yyyy mm/dd/yyyyi have an argue about this with my parnerts, cause i think is imposible, if you don't have a format before the process runs.
I am trying to transfer some tables and stored procedures from SQL Server 2005 to Express 2008. I have tried using Management studio, but it isn't working....
I have a table with 100 records. I need to import extra 50 records in the same table. So from 101 to 150 records should insert the data which is present in excel Simply I want to import 50 records from Excel to Table without disturbing the first 100 records.
I need to have a server log that will help to determine the number of items entered into the db and where those items are entered, without having query each table. It should be able to give me the average monthly volume of items input in SQL.
Can this be done using Sql Triggers or any other alternative?
I have to make sure that if I use trigger as the alternative I should have only one table to be updated with all the details of the Updates/Inserts being inserted into the Trigger table after the insertion into the original table.
Below given are some of the create table statements that I have for which I need to have a server log of the updates & inserts.
I am attempting to insert into two tables at once, but it's inserting blank values into the first table, and then correctly inserting the values into the second table. here is my codebehind, I can post the rest of my code if needed.
[code]...
Even when I comment out the second insert command, the first one still inserts null values.
I've used the Import/Export wizard to get data into SQL from Excel and it works great. When I want to reverse the process, however, I can't. I've gone through the wizard multiple times and I've done what I think is everything to try to get the data out. What am I doing wrong?