473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Insert Web Interface records to SQL database table on Button click

Please tell me how to Insert Web Interface records to SQL database table on Button click

I have several records for approving payment
and these records needs to be inserted into a table Payment List
(which is already created) and when i click confirm payment button the records need to be inserted to the payment list table and payment id is generated automatically and the table column Agency approval has to get a boolean value 1 if approved

Please suggest

Thanks,
George
Sep 4 '07 #1
3 3639
jhardman
3,406 Expert 2GB
George,

OK, so what do you have so far? There is a simple tutorial in the ASP Articles section on how to insert records into a db. Let me know if this doesn't answer all of your questions. I'm willing to help, but if you would like one of our experts to do the job for you, it would be better to post in the jobs section.

Jared
Sep 5 '07 #2
Thanks for your reply jhardman,
I shall look into the articles too now.
Here is where i am right now
Expand|Select|Wrap|Line Numbers
  1. // getting records on Review data grid view  View ID = ReviewSelectionGD
  2. This is the code where i get the data to temp table and then displayed on the reviewdata datagrid page and here the records need to be inserted  into the database table
  3. // (This works Fine)
  4.  
  5. //
  6. protected
  7.  
  8. void ProcPaymBTM_Click(object sender, EventArgs e) 
  9. {
  10. if (Dataviewlisting.ActiveViewIndex < 2) 
  11. {
  12. Dataviewlisting.ActiveViewIndex += 1;
  13. }
  14. int IndexCount = 0; 
  15.  
  16. String ProcessingPayment; 
  17. SessionValues ValueSelected = 
  18.  
  19. null; 
  20. DataTable SelectedPayment = 
  21.  
  22. new DataTable(); 
  23.  
  24. //GridView DataListSelected = (GridView) e; 
  25.  
  26. if (Session[Session_UserSPersonalData] == null) 
  27. {
  28.  
  29. ValueSelected = 
  30.  
  31. new SessionValues(); 
  32. Session.Add(Session_UserSPersonalData, ValueSelected);
  33. }
  34.  
  35. else 
  36. {
  37.  
  38. ValueSelected = (SessionValues)(Session[Session_UserSPersonalData]);
  39.  
  40. }
  41.  
  42. ProcessingPayment = ValueSelected.PaymentSelected;
  43. switch (ProcessingPayment) 
  44. {
  45.  
  46. case "EnollNotPaidBTM": 
  47.  
  48. break; 
  49.  
  50. case "PlacNotPaidBTM": 
  51.  
  52. break; 
  53.  
  54. case "Ret1NotPaidBTM": 
  55.  
  56. break; 
  57.  
  58. case "Ret3NotPaidBTM": 
  59.  
  60. break; 
  61.  
  62. case "Ret6NotPaidBTM": 
  63.  
  64. break; 
  65.  
  66. case "Place2ndNotPaidBTM": 
  67.  
  68. break; 
  69.  
  70. case "EnrollBonusNotPaidBTM": 
  71.  
  72. break; 
  73.  
  74. case "WPRNotPaidBTM": 
  75.  
  76. break; 
  77.  
  78. case "SatisCompleteNotPaidBTM": 
  79.  
  80. break; 
  81.  
  82. default: 
  83.  
  84. break; 
  85. }
  86.  
  87. Titlelb.Text = ""; 
  88.  
  89. // copy this code to each Case 
  90.  
  91. // ************************************************* 
  92.  
  93. // Revies the list to see what payment has being approve 
  94.  
  95. foreach (GridViewRow SelectedRows in this .DetailDataList.Rows) 
  96.  
  97.  
  98.  if (((CheckBox)SelectedRows.FindControl("ApprovalCk")).Checked) 
  99. {
  100.  
  101. IndexCount += 1;
  102.  
  103.  // Setting the index the identified if the record is already in the approval list. 
  104.  
  105. int valueAlreadyProcess = -1; 
  106.  
  107. // Checking for existent and process records 
  108.  
  109. try 
  110. {
  111.  
  112. ValueSelected.TemporaryTable.DefaultView.Sort = 
  113.  
  114. "SSN"; 
  115. valueAlreadyProcess = ValueSelected.TemporaryTable.DefaultView.Find(SelectedRows.Cells[3].Text);
  116. }
  117.  
  118.  catch 
  119. {
  120.  
  121.  // Not space allocated for the table. The table is empty 
  122. }
  123.  
  124.  if (valueAlreadyProcess == -1) 
  125. {
  126.  
  127.  // Create a new row to save the approve payment 
  128. DataRow DataRowCollection = ValueSelected.TemporaryTable.NewRow();
  129.  
  130. for (int ColInd = 3; ColInd < (ValueSelected.TemporaryTable.Columns.Count + 3); ColInd++) 
  131. {
  132.  
  133.  try 
  134. {
  135.  
  136.  if (SelectedRows.Cells[ColInd].Text != "&nbsp;") 
  137. {
  138.  
  139. DataRowCollection[ColInd - 3] = SelectedRows.Cells[ColInd].Text;
  140.  
  141. }
  142.  
  143.  else 
  144. {
  145.  
  146.  // No term code value 
  147. }
  148. }
  149.  
  150.  catch 
  151. {
  152.  
  153. // No Value in the Grid View for date or termination 
  154. }
  155.  
  156. }
  157.  
  158. // collect the comment information 
  159. TextBox CommentAdded;
  160.  
  161. CommentAdded = (TextBox)SelectedRows.FindControl(
  162.  
  163. "CommentsBx"); 
  164. DataRowCollection[
  165.  
  166. "Comments"] = CommentAdded.Text; 
  167.  // save the approve information into the temporary infomation 
  168. ValueSelected.TemporaryTable.Rows.Add(DataRowCollection);
  169.  
  170. }
  171. }
  172.  
  173. // Displaying the data selected 
  174. ReviewSelectionGD.DataSource = ValueSelected.TemporaryTable;
  175.  
  176. ReviewSelectionGD.DataBind();
  177.  
  178.  }
  179.  
  180.  // ************************************************* 
  181. }
  182.  
  183.  [Edit Tags]
  184.  
  185. // ??? NOw for inserting records from datagrid view to SQL table
I am using the following codes for inserting records but it shows errors...please help
Expand|Select|Wrap|Line Numbers
  1. //---- CS file/Code behind ---
  2.  
  3. protected void ReviewSelectionGDInsert_ItemCommand(object sender, DetailsViewCommandEventArgs e) 
  4. {
  5.  
  6. if (e.CommandName.Equals("Insert")) 
  7. {
  8.  
  9. ReviewSelectionGD.Insert();
  10.  
  11. }
  12.  
  13. }
  14.  
  15. protected void ComfPaymBRM_Click(object sender,EventArgs e) 
  16. {
  17.  
  18. string SSN = ((TextBox)ReviewSelectionGD.FindControl("SSN")).Text; 
  19. string JC_ID = ((TextBox)ReviewSelectionGD.FindControl("JC_ID")).Text;
  20.  
  21. string AGENCY_ID = ((TextBox)ReviewSelectionGD.FindControl("AGENCY_ID")).Text; 
  22. string Agency_approval = ((TextBox)ReviewSelectionGD.FindControl("Agency_approval")).Text;
  23.  
  24. string Agency_approval_date = ((DropDownList)ReviewSelectionGD.FindControl("Agency_approval_date")).Text; 
  25. e.InputParameters.Add("SSN", "");
  26.  
  27. e.InputParameters.Add("JC_ID", ""); 
  28. e.InputParameters.Add("AGENCY_ID", "");
  29.  
  30. e.InputParameters.Add("Agency_approval", 1);e.InputParameters.Add("Agency_approval_date", getdate()); 
  31.  
  32. }
  33.  
  34. protected void ReviewSelectionGD_Inserted(object sender, ObjectDataSourceStatusEventArgs e) 
  35. {
  36.  
  37. if (e.Exception != null) 
  38. {
  39.  
  40. DivResult.Visible = true; 
  41. }
  42.  
  43. else
  44.  
  45. {
  46.  
  47. // TODO 
  48.  
  49. }
  50. }
  51.  
  52. //BLL/DAL 
  53.  
  54. public static int InsertPayment( 
  55. int SSN,
  56.  
  57. int JC_ID, 
  58. int AGENCY_ID,
  59.  
  60. int Agency_approval,DateTime Agency_approval_date 
  61.  )
  62. {
  63. int rowsAffected = 0;using (SqlConnection connection = ConnectionManager.GetFinanceDBConnection()) 
  64. {
  65.  
  66. SqlCommand command = new SqlCommand("InsertPaymentList", connection); 
  67. command.CommandType = CommandType.StoredProcedure;
  68.  
  69. command.Parameters.Add("@SSN", SqlDbType.VarChar).Value = SSN;
  70.  
  71. command.Parameters.Add("@JC_ID", SqlDbType.VarChar).Value = JC_ID; 
  72. command.Parameters.Add("@AGENCY_ID", SqlDbType.VarChar).Value = AGENCY_ID;
  73.  
  74. command.Parameters.Add("@Agency_approval", SqlDbType.VarChar).Value = Agency_approval;command.Parameters.Add("@Agency_approval_date", SqlDbType.datetime).Value = Agency_approval_date; 
  75.  
  76. rowsAffected = command.ExecuteNonQuery();
  77.  
  78. }
  79.  
  80. return rowsAffected; 
  81. }
  82.  
  83. //stored procedure
  84.  
  85. ALTER PROCEDURE [dbo].[InsertPaymentList](
  86.  
  87. @SSN VARCHAR(50), 
  88. @JC_ID int ,
  89.  
  90. @AGENCY_ID VARCHAR(50),
  91.  
  92. @Agency_approval int,
  93.  
  94. @Agency_approval_date datetime)
  95.  
  96. AS
  97.  
  98. INSERT INTO Payment_LIST_AIMS 
  99. (SSN,JC_ID,AGENCY_ID,Agency_approval,Agency_approval_date)
  100.  
  101. VALUES
  102.  
  103. (@SSN,@JC_ID,@AGENCY_ID,@Agency_approval,@Agency_approval_date)
  104.  
  105. SET @SSN = SCOPE_IDENTITY()
  106.  
[Edit Tags]
Sep 5 '07 #3
jhardman
3,406 Expert 2GB
George,

This doesn't look like ASP classic. Is this ASP.NET? What language are you using?

Jared
Sep 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
2
by: Tom Gao | last post by:
I have a problem. The project that I'm working on requires me to duplicate records. As in a series of records are entered into the system the user then click on a button to make these as...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
2
by: User | last post by:
Hi ! I have a sql insert function with a buttonin my page, and when i click on refresh button of IE. When i click my button, i have a new records but after when i click on the refresh button of IE...
1
by: hellyna | last post by:
How to insert radiobutton value into the mysql? This is addrecordfrom.php <form name="addsummonrecord" method="post" action="addrecordprocess.php" id="signup" onSubmit="return...
6
by: Christopher Lusardi | last post by:
How can I fix this? When I do the below I get the error message: "Cannot insert explict value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF." To get this message,...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
0
by: Steven Blair | last post by:
Hi, Would be grateful if anyone with a high understanding of the SqlDataSource and FormView could have a look at my example and my problems. This has really been puzzling me for some time, and...
0
BenRatcliffe
by: BenRatcliffe | last post by:
Hi there, I was wondering if anyone could help me. I have a comlpex database with a number of forms that have data entered on them and then saved into the correct table etc. In this instance I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.