HI
I want to insert multiple values of checkbox list in single column seperated by comma.my insert code is
---------------------------------------
SQL CODE
Insert into PR_LWFSetting(SrNo, MonApp ) Select SrNo, MonApp From OPENXML (@DocPR_LWFSetting, '/PR_LWFSetting/Row',2)
WITH ( SrNo int 'SrNo',
MonApp varchar(50) 'MonApp' )
------------------------------------------
ASP .NET
save code
xmlPR_LWFSetting.Append("");
xmlPR_LWFSetting.Append(SelectedValue);
//xmlPR_LWFSetting.Append(this.chkMonth.SelectedValue)xmlPR_LWFSetting.Append("");
where code for SelectedValue is
string SelectedValue = string.Empty, blankValue = string.Empty;
foreach (ListItem item in chkMonth.Items)
{
if (item.Selected)
{
SelectedValue += item.Value + ",";
}
else
{
blankValue += item.Value + ",";
}
}
I am getting an error
Conversion failed when converting the varchar value '1,2,' to data type int
Jaganathan BantheswaranPosted Oct 26, 2013, 10:08 AM
You cant use OPENXML with commma separated values.
The format of the input should a xml string like the below example.
declare @xmlString = '
INSERT INTO CriteriaTable ([Name], [Value] )
SELECT name, value FROM OPENXML(@xmlString, '/example/values',1) WITH (name varchar(25), value varchar(50))