After creating a dataset, which has CRUD statements generated two or more tables, which Data Control should I use that will allow me to insert data into fields into 2 or more tables from a single web form. I'm trying to create a web form that will allow the user to input student information, such as general information, medical information, etc.
how to run multiple queries on a single button click. Actually I want whatever a user write in text box and click the button the text would get inserted in table category and also a table name project should get updated. I am using Sql server 2005 and c#
I have a grid with three columns, two of which contain drop-downs, all of them getting filled from a web service result set. Now I want to allow the functionality of adding a new record in the grid by clicking an Add button present outside the gridview.
Whenever the user clicks the Add button, a new record should be created in the grid with value list filled in the drop-downs with the available options.
What is the best possible way to achieve this considering extensibility in mind.
I have got a page in which there is a file upload option where I have to upload/import the csv file. What I want to do is to check if the correct format of file is uploaded for instance if any other than csv file is uploaded, the system should give an error message. Also what I need to do is to check certain fields of the csv file for instance there are some mandatory fields in the csv file which should be there like name , postcode, How can I check that these fields are not empty . After performing these task, the system should automatically upload the csv file onto the sql sever 2008.
datatable t = new DataTable; DataColum C1 = new DataColum;//ID column t.Columns.Add(C1); //the same with column C2
Then I fill up the table with some data. Then the goal is to either insert this data or update data in an SQLtable in SQL. If the data is inserted, the ID column in t would be empty, if updated, it would not be. So in the insertion case, the sql query needs to make sure that unique IDs are assigned during insertion, in the update case, it just has to look for the right IDs.How to go about this? Asking because I am only familiar with updating and inserting single lines into a table. One could loop in C# over the datatable t of course and insert or update line by line, but this would probably be slow. Is there a way to write an SQL query like this somehow:
Insert Into SQLTable Values (@t) ? And Update like this: Update SQLTable SET ... Where C1 = @t.C1 Or something like that. I know that SQL server can create automatic update and insert queries and that you can then type things in C# like
Adapter.Update(t);
But, this has proven to be super slow on our server, for unknown reasons. I have asked on this forum and got some answers from experts, but was not able to srot out the problem. How can we write a custom SQL query that allow updating and inserting a whole table, instead of just one line at a time?
I have a webform page that has a formview, gridview and two sqldatasources. The formview has many fields and an edit button. When a user attempts to edit the formview i want to create a seperate log record that contains datetime, username, and couple other fields from the formview. I want this log record to appear below the formview in a simple gridview. I know theoretically i can create a sql trigger but dont know how to pass the data into it. So i believe the logic is to have c# do it in the code behind during "itemUpdating" except i am struggling with stringing the values from the formview and using them in the sql insert statement, not to mention i am a asp.net newbie! i created this sql statement in itemUpdating, but this as far as my experience can take me.
con.ConnectionString = cmd.Connection = con; cmd.CommandText = SqlConnection con = new SqlConnection(); "Data Source=LocalSqlServer;Initial Catalog=wilsonhs;Integrated Security=SSPI";SqlCommand cmd = new SqlCommand();"INSERT INTO [detentionLog] ([updated], [updatedBy], [ViolationID]) VALUES (@updated, @updatedBy, @ViolationID)"; cmd.ExecuteNonQuery();
on my webpage having 5 gridview n when m click on PrintAll ... it combine all record in one gridview .....so wt can i do to get the Gridview as it is on after print .......n m rendering Div nt gridview . attaching code also.
my requirement is like i want to insert data to table after caliculation like table name salaryhike columns salaryinput,20%hike, 25%hike and 30%hike salaryinput column details to be input by the user and hike is to be caliculated and inserted with 20%hike, 25%hike and 30%hike are columns of same table.
I'm having some problems with the interface I've created. I am getting value and ids in a string using for loop on the controls(objects). After some searching, I've discovered that it isinserting an empty string into my database fields as opposed to an null value. I need my application to insert NULL values, not emptry strings. Can any one suggest me on this and also how can i prevent sql injection on the above code. because i am passing like following :
@variable1='Name,Address,Remarks' //(as a Column name) @variable2='Pritesh,Mumbai,any remark' //(as a column value for above.) exec myprocedure 'tablename','@variable1','@variable2'.
if any one pass single inverted comma in the above column value in @variable2. my code give me error. how can i prevent this sql injections..
I am developing an application using ASP.NET 3.5 with C#. In my application I have a gridview control and inside the template field of gridview I have placed a RadioButton. When I run the application and when I try to select a single radio button, it allows multiple selection of radio buttons. I have to select a single radio button.
I created a gridview that is bound with an SQL datasource - I added a gridview button column. I need to update/insert 'Y' on a specific cell in the row when I press the button
This is my gridview code
[code]....
The button column I have says delete on it but it shouldn't really delete it - Once I press the button it puts a 'Y' on a column that is filtered out by my sql statement in the sql datasource
i have two checkboxes in two templete fileds in a gridview .but i want to uncheck only single checkbox when i click on button which is ouside of the grid,
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 am writing code to insert values from an xml file. I check for a duplicate before inserting and delete if there is a match. Is there a more effecient way to prevent duplicates before insert a record? my code: private void LoadFData() { SqlConnection oConn = new SqlConnection(ConnectionString); SqlCommand oCommand = new SqlCommand(); oCommand.Connection = oConn; oCommand.CommandType = CommandType.Text; oConn.Open(); // Load committee master files string[] strFiles = System.IO.Directory.GetFiles("fff", "ffff.dta", System.IO.SearchOption.AllDirectories); for (int i=0; i
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]
Here I'm using three tables given below. As u can see in the below three tables, 3 columns(P_Id,PdtName,PdtImgUrl) are same. Now can any body tell me how can I retreive values of 3 columns(P_Id,PdtName,PdtImgUrl) without repeatition.