Click to See Complete Forum and Search --> : How to Insert Web Interface records to SQL database table on Button click


svgeorge
September 4th, 2007, 09:22 AM
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

jasonli
September 4th, 2007, 09:27 AM
C'mon, there are many ways to do this. Why do you just keep asking? Learn ADO.NET.

svgeorge
September 4th, 2007, 09:32 AM
I am seeking suggestion from the forum as individuals who wish to help need post me .Is that clear !!!

svgeorge
September 4th, 2007, 11:00 AM
Here i need to insert onlly those records from that session i collected in Temp table from earlier Datagrid View to another Final datagrid view where the data is prior to inserting to database
Can any one suggest

svgeorge
September 5th, 2007, 08:41 AM
http://twd1/mgsweb/financepayment.aspx

This is the link for the web interface....click and see

svgeorge
September 5th, 2007, 01:32 PM
I am using the following codes for inserting records to SQL SERVER Database table but it shows errors...please help

//---- CS file/Code behind ---

protected void ReviewSelectionGDInsert_ItemCommand(object sender, DetailsViewCommandEventArgs e)

{

if (e.CommandName.Equals("Insert"))

{

ReviewSelectionGD.Insert();

}

}

protected void ComfPaymBRM_Click(object sender,EventArgs e)

{

string SSN = ((TextBox)ReviewSelectionGD.FindControl("SSN")).Text;

string JC_ID = ((TextBox)ReviewSelectionGD.FindControl("JC_ID")).Text;

string AGENCY_ID = ((TextBox)ReviewSelectionGD.FindControl("AGENCY_ID")).Text;

string Agency_approval = ((TextBox)ReviewSelectionGD.FindControl("Agency_approval")).Text;

string Agency_approval_date = ((DropDownList)ReviewSelectionGD.FindControl("Agency_approval_date")).Text;

e.InputParameters.Add("SSN", "");

e.InputParameters.Add("JC_ID", "");

e.InputParameters.Add("AGENCY_ID", "");

e.InputParameters.Add("Agency_approval", 1);

e.InputParameters.Add("Agency_approval_date", getdate());


}

protected void ReviewSelectionGD_Inserted(object sender, ObjectDataSourceStatusEventArgs e)

{

if (e.Exception != null)

{

DivResult.Visible = true;

}

else

{

// TODO



}

}


//BLL/DAL

public static int InsertPayment(

int SSN,

int JC_ID,

int AGENCY_ID,

int Agency_approval,

DateTime Agency_approval_date


)

{

int rowsAffected = 0;

using (SqlConnection connection = ConnectionManager.GetFinanceDBConnection())

{

SqlCommand command = new SqlCommand("InsertPaymentList", connection);

command.CommandType = CommandType.StoredProcedure;

command.Parameters.Add("@SSN", SqlDbType.VarChar).Value = SSN;

command.Parameters.Add("@JC_ID", SqlDbType.VarChar).Value = JC_ID;

command.Parameters.Add("@AGENCY_ID", SqlDbType.VarChar).Value = AGENCY_ID;

command.Parameters.Add("@Agency_approval", SqlDbType.VarChar).Value = Agency_approval;

command.Parameters.Add("@Agency_approval_date", SqlDbType.datetime).Value = Agency_approval_date;


rowsAffected = command.ExecuteNonQuery();


}

return rowsAffected;

}

//stored procedure

ALTER PROCEDURE [dbo].[InsertPaymentList](

@SSN VARCHAR(50),

@JC_ID int ,

@AGENCY_ID VARCHAR(50),

@Agency_approval int,

@Agency_approval_date datetime)

AS

INSERT INTO Payment_LIST_AIMS

(SSN,JC_ID,AGENCY_ID,Agency_approval,Agency_approval_date)

VALUES

(@SSN,@JC_ID,@AGENCY_ID,@Agency_approval,@Agency_approval_date)

SET @SSN = SCOPE_IDENTITY()