Wednesday, 30 May 2012

How to convert the table values to XML file and XSD file

SqlConnection Con = new SqlConnection("server=.;uid=.;Pwd=.;database=.");
SqlDataAdapter da = new SqlDataAdapter("Select top 10 * from SoftLawrence", Con);
DataSet DS = new DataSet();
da.Fill(DS);
DS.WriteXml("F:\\SoftLawrence\\Sample.XML");
DS.WriteXmlSchema("F:\\SoftLawrence\\Test.XSD");

//To convert the Xml file to Dataset
DataSet dsVat = new DataSet();
string appPath =  GetExecutingPath();
dsVat.ReadXml(appPath + "Sample.xml");
 return dsVat;

Wednesday, 16 May 2012

To give Bold in the particular word of the Asp label control text

<asp:Label ID="lblText" runat ="server" Text="To attach a file, type the path of the file in the field below or click on the &lt;b&gt;Browse&lt;/b&gt; button to locate it in your computer." />

Tuesday, 1 May 2012

Use of COALESCE in the SQL Server

DECLARE @RegistrationNo VARCHAR(1000);    

                    SELECT  @RegistrationNo = COALESCE( CASE WHEN CAST(@RegistrationNo AS VARCHAR(1000)) IS NOT NULL AND @RegistrationNo<>'' then CAST(@RegistrationNo AS VARCHAR(1000)) + ', ' end, '') +''+ CAST(RegistrationNo AS VARCHAR(100))   

                    FROM Table_Name

                    SELECT '[' + @RegistrationNo + ']'