For some reason, the if statement below is not working
''# count if records with this user already exist in the database below
objSQLCommand = New SqlCommand("select count(id) as record_count from table1 where user = @strUser", objSQLConnection)
objSQLCommand.Parameters.Add("@strUser", SqlDbType.VarChar, 3).Value = strUser
objSQLCommand.Connection.Open()
intRecordCount = CType(objSQLCommand.ExecuteScalar(), Integer)
objSQLCommand.Connection.Close()
''# duplicate default rows in database if username not in database
If intRecordCount = 0 Then
Response.Write(intRecordCount)
objSQLCommand = New SqlCommand("insert into table1 (heading, user) select heading, @strUser as user from table1 where defaults = @intDefault", objSQLConnection)
objSQLCommand.Parameters.Add("@strUser", SqlDbType.VarChar, 3).Value = strUser
objSQLCommand.Parameters.Add("@intDefault", SqlDbType.Int, 4).Value = 1
End If
Response.Write(intRecordCount) returns a 0 if 0 records are found and it returns 2 if i manually insert 2 rows for the user in the database. But for some reason, the if statement does not work. If I run the "insert select" query manually, it works perfectly.
I've built a complex site for a client, who wants this duplicated, and re-skinned, so it can be used for other means. What is the best way of doing this? I'm concerned about copying every file as this means any bugs must be fixed twice, and any improvements must be implmented twice.
I have a question regarding the duplication of properties within view models. For my Search View i have a viewmodel that looks like this
public class SearchModel { public IEnumerable<SelectListItem> Genders {get;set;} ... other select lists // Worker Details public string FirstName {get;set;} public string LastName {get;set;} public DateTime Birthdate {get;set;} public int Phone {get;set;}et public string Gender {get; set;} //Address Details public string Street {get;set;} public string City {get;set;} public string Zip {get; set;} } For my Input View i have the following View Model public IEnumerable<SelectListItem> Genders {get;set;} public IEnumerable<SelectListItem> Directions {get;set;} ... other select lists // Worker Details public string FirstName {get;set;} public string LastName {get;set;} public DateTime Birthdate {get;set;} public int Phone {get;set;}et public string Gender {get; set;} public string SSN {get; set;} public string DL {get;set;} //Address Details public int Number {get;set;} public string Direction {get;set;} public string Suffix {get;set;} ..... public string Street {get;set;} public string City {get;set;} public string Zip {get; set;} } List Display Model public class ListDisplayModel { public IEnumerable<Worker> Workers {get;set;} internal class Worker { public string FirstName {get;set;} public string LastName {get;set;} public DateTime Birthdate {get;set;} public int Phone {get;set;}et public string Gender {get; set;} public string SSN {get; set;} public string DL {get;set;} //Address Details public int Number {get;set;} public string Direction {get;set;} public string Suffix {get;set;} public string Street {get;set;} public string City {get;set;} public string Zip {get; set;} } }
I feel like i'm duplicating a lot of properties. I was wondering if it would be ideal for me to go ahead and create like a DTO class called worker and just place it in each of these view model classes or is there a better way to do something like this?
I need to copy the records of a row to the next available row in the same table. I tried with "Insert ...Select " but it throws me a error since the pk is auto-increment. Also, i cant specify each and every column inside the insert...select statment cause i've almost 30 columns.
I am populating 4 drop down lists. The dropdownlists within the For loop work fine and I will ignore these for the rest of this post. Reading the code below should add 2 values to the dropdownlist ddlPost and should add 2 values to the dropdownlist ddlTailLength. Both values should be A and B. Both of these drop lists should show 2 values (A and B), but are showing 4 values each (A, B, A, B). The only loop on these pages is the one displayed below.
I'm trying to work on this page that requires me to have a hyperlink/button that, when clicked, should duplicate a section of a page which includes several text fields, radio buttons, a dynamic table (where the user can add rows and edit fields), and the actual link itself. Is this possible? If so, could someone please show me how? :( I'm really stumped on how to do this one.
Many years ago I built a website for a customer in classic asp that uses RomanCart as the payment gateway. This has worked very well, but ive now been given the task of rebuilding the site under .net 3.5 the old site used a submit button that set the action to the romancart url and setup some hidden field values. I want to duplicate this behaviour in the .aspx page from the onclick event of a button. Heres the origianl code from the classic asp page.Can Anyone give some some pointers in converting this to c#?
I have two UpdatePanels on a page. The first one works perfectly. The other one works as well, but when it is updated. A table nested inside the <ContentTemplate> is duplicated...meaning that where there was 1 there are now 2 exact copies. Otherwise everything appears to be operating fine. Both UpdatePanels have the UpdateMode set to "Conditional".
I've used modal popups before with no issues, but now I am getting a strange issue I need help with.I'm using .net 4.0, this is my first new project using it, so perhaps it is something to do with that.
I've setup a modal popup which contains textboxes and a dropdownlist to insert and update values in a database. The popup displays correctly, and the code behind works perfectly to insert new rows into a database and update existing ones. My problem is, it's inserting and updating 'incorrect values'. If I type "test123" into the textbox and save it, the value "test123,test123" is saved. I do not have any code that does this, and i think it is the modal popup extender, because when I move controls out of the modal popup panel and onto the main page (inside an update panel) they are no longer affected by 'duplicating' string values and "test123" is saved. ",<duplicateValue>" is appended after EVERY post back. I've had the textbox displaying "test123,test123,test,123,test123" after a few save button clicks. Is there anything blatantly obvious to check (viewstate or something similar) that will correct this behaviour? I promise I'm not duplicating the values myself, they only seem to duplicate after the submit button click inside the modal popup panel.
I was wondering if anyone has come across what seems like a bug (though I'm fully updated and can't find reference to this anyway) in Visual Studio.
I've a CreateUserWizard and in some of the steps, it appears to be duplicating HTML inside of itself when I switch step views.
Step 2, for example says "please enter your first name", once I view step 2, or 3 etc, step 2 generates "please enter your first nameplease enter your first nameplease enter your first nameplease enter your first name".
This is inside the actual aspx file so is surely an issue with Visual Studio, but I can't work out how to solve it.
I've looked for broken tags or incorrect values that may be confusing it, but can find none.
I would like to duplicate a table record but not all the columns.For example, Select from "TableA" Where recordid='1' AND insert into "TableA" All values except "col2" , "col3". I hope you got the idea. Could you please advise me what is the cleanest approach to get this done.
There is a similar instance of this @ http://forums.asp.net/p/1380776/2919093.aspx#2919093 However I haven't had a response, maybe due to the age of the topic, but the problem is different in the sense I am not using AJAX Rating Control, I am using radio buttons contained in a Div named Ratings, which is picked up by jQuery to style to radio buttons accordingly.The output is that it will put the stars on the first record but anything after just shows origionalunstyled radio buttons.Just thinking off the top of my head, but does anything need to be put in the ItemDataBound event?The jQuery for the stars etc were attained from the link below:http://orkans-tmp.22web.net/star_rating/index.html#demos=&main-menu=0&demo-tabs=3Here is my code:.ASPX:
is it possible to create a function which will duplicate textboxes and label when a button is pressed. For example: I have Name and address textboxes and labels
Is there anyway of doing this? Its hard to explain which is why google is not my friend on this topic. But this would be neat an example may be.
Player 1 Player 2 Player 3 Player 4
Button - Add Additional Players When the button is pressed an additional player is added. Am trying my best to explain it to you, but is it possible in C# and ASP.NET?
here is my query which is not working properly. I have 5 fields in my table Company, Reseller, Item, Code, Price. How can i get minimum Price when i pass parameters for Code is dublication value
Company Reseller Item Code Price A A-1 I1 C1 20 B A-21 I2 C2 13 C A-B I1 C1 19
select Company,Reseller,Item,Code,Min(Price) from Table1 where code='C1' order by Code HOW CAN I GET THIS BELOW TYPE OF RESULT
Company Reseller Item Code Price A A-1 I1 C1 20 C A-B I1 C1 19
I am new here,I have a grid with some checked & unchecked check boxes,& on click button of asp.net i want to add the checked rows to database,so which method will be best ?
I have a combobox which is populated by id which is there in a database. And two Textboxes Name,Sal to insert Name and Salary of the Employee. I have no problem in inserting the datas to database and viewing all the inserted datas.
I got issue when I tried to view name and salary of the employee when a particular id is selected from combobox and finally clicking on a button to get the name and salary in the textboxes.
string str = ComboBoxName.getSelectedItem();
and a command as :"Select name,sal from Emp where id = +str"
I am working on a web page that will display records from a database. Each record has a total of 8 columns. One column may be as long as 500 characters, and the other 7 columns are between 5 to 25 characters. For each record in the dataset returned from the database, the short columns should be above, and the long column below.
In other words, each database record is made of two rows, the 7 short fields in the top row (each field in a cell), and the long field in the bottom row in one cell. Both rows should be similar in length.
I am Developing Windows Form Application in .Net, I want to insert selected rows value of Gridview into database. First Column of my GridView is Checkbox, when user check one or more checkbox from gridview, i want to insert values of respective rows into Database. In Web application i done this using DataKeyNames property of GridView. Want to know how to do it in Windows Form Application. I am using Visual Studio 2005.
I want to select many rows from my SQL Server database and combine them in a certain manner. Currently, I've been using the following method to get these rows:
Never really worked with the asp tables but for this project it makes more sense, I am having trouble addding rows dynamically from the sql datatable i am pulling. In hte datatable it has 12 rows with 14 columns, I need to make this into a table, with a dtagrid I would be done but I have to pull other data that they could add columns, so a table I am told is easier.
This gets my data and I can see it
mydataTable = new DataTable mydataTable = GetData(sql) mydataTable.add.row(myDataTable.rows(0)(0))
I get nothing but errors trying to do this, what is the correct way to add rows to an asp.net table
Can I add this all to a datagrid and then add the extra columns I need if they are there with out using a table.