//create dataset which will have all data DataSet ds1 = new DataSet("XML data1"); //load schema first, this is updates schema will attch with email ds1.ReadXmlSchema(@"D:\userdocs\Ken_XML\FAC_SSIS_Identities\output.xsd"); ds1.EnforceConstraints = false; //load data in dataset ds1.ReadXml(@"<XML file>"); //connect to sql server and appropriate database see if table already present, if not present create new table after that load data from dataset to sql using bulkcopy try { SqlConnection conn = new SqlConnection("Server=localhost;Initial Catalog= XML_data;Trusted_Connection=True;"); conn.Open(); foreach (DataTable dt in ds1.Tables) { //check if table is present or not string exists = null; try { SqlCommand cmd = new SqlCommand("SELECT * FROM sysobjects where name = '" + dt.TableName + "'", conn); exists = cmd.ExecuteScalar().ToString(); }catch (Exception exce) { exists = null; } // selecting each column of the datatable to create a table in the database Console.WriteLine("Bulk Insert Started table:" + dt.TableName); SqlBulkCopy bulk = new SqlBulkCopy(conn); bulk.DestinationTableName = "[" + dt.TableName + "]"; foreach (DataColumn dc in dt.Columns) { bulk.ColumnMappings.Add(dc.ColumnName, dc.ColumnName); string type = ""; //Getting right data type for column is very importatnt as it can create problem later if wrong data type is chosen //for mapping we are using below key value pair //Dictionary<string, string> typemappings = new Dictionary<string, string>(); //typemappings.Add("Decimal", "Numeric"); //typemappings.Add("String", "varchar(255)"); //typemappings.Add("Int32", "Int"); typemappings.TryGetValue(dc.DataType.FullName.Split('.')[1], out type); if (type == null) type = "varchar(255)"; if (exists == null) { SqlCommand createtable = new SqlCommand("CREATE TABLE [" + dt.TableName + "] ([" + dc.ColumnName + "] " + type + ")", conn); createtable.ExecuteNonQuery(); exists = dt.TableName; } else { try { SqlCommand addcolumn = new SqlCommand("ALTER TABLE [" + dt.TableName + "] ADD [" + dc.ColumnName + "] " + type, conn); addcolumn.ExecuteNonQuery(); }catch (Exception ex2) { } } } //load data in sql bulk.WriteToServer(dt); Console.WriteLine("Bulk Insert completed table:" + dt.TableName); } conn.Close() }catch (Exception ex) { Console.WriteLine(ex.Message.ToString() + "\n" + ex.StackTrace.ToString()); } finally { ds1.Clear(); ds1.Dispose(); }
Here you will find about .net technology. also can get example about MVC.net and jquery.
Thursday, January 16, 2014
Fastest way to Import data from XML to SQL asp.net
Thursday, November 28, 2013
hide div after 5 seconds javascript
function hidemsg() {
setTimeout(function () {
$("#" + '<%=lblSkillmsg.ClientID%>').hide('blind', {}, 500)
}, 5000);
}
you can set second also (5000 change to 6000 or etc.)
setTimeout(function () {
$("#" + '<%=lblSkillmsg.ClientID%>').hide('blind', {}, 500)
}, 5000);
}
you can set second also (5000 change to 6000 or etc.)
Friday, November 22, 2013
prevent a password input from clearing after submit asp.net
You require to set it again in page_load or in button click event like this :
string Password = txtPassword.Text;
txtPassword.Attributes.Add("value", Password);
get the value from radiobuttonlist through javascript asp.net
<form runat="server">
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal" RepeatLayout="flow" >
<asp:ListItem Selected="True" Text ="Yes" Value="0"></asp:ListItem>
<asp:ListItem Text ="No" Value="1"></asp:ListItem>
</asp:RadioButtonList> </form>
<p id="button" onclick="getvalue()">click me</p>
<script type="text/javascript">
function getvalue(){
alert($('#<%=RadioButtonList1.ClientID %> input[type=radio]:checked').val());
}
</script>
Thursday, October 31, 2013
14 Rules for Faster-Loading Web Sites
- These rules are the key to speeding up your web pages.
They've been tested on some of the most popular sites on the Internet
and have successfully reduced the response times of those pages by 25-50%.
The key insight behind these best practices is the realization that
only 10-20% of the total end-user response time is spent getting the HTML document to the browser.
You need to focus on the other 80-90% if you want to make your pages noticeably faster.
These rules are the best practices for optimizing the way servers and browsers handle that 80-90% of the user experience.
- Rule 1 - Make Fewer HTTP Requests
- Rule 2 - Use a Content Delivery Network
- Rule 3 - Add an Expires Header
- Rule 4 - Gzip Components
- Rule 5 - Put Stylesheets at the Top
- Rule 6 - Put Scripts at the Bottom
- Rule 7 - Avoid CSS Expressions
- Rule 8 - Make JavaScript and CSS External
- Rule 9 - Reduce DNS Lookups
- Rule 10 - Minify JavaScript
- Rule 11 - Avoid Redirects
- Rule 12 - Remove Duplicate Scripts
- Rule 13 - Configure ETags
- Rule 14 - Make AJAX Cacheable
Wednesday, October 16, 2013
Date Condition in Case statement sql Server
SELECT
C.CategoryID
,
CategoryName ,
CASE WHEN ABS(DATEDIFF(W,GETDATE(),R.CreatedDate)) <= 5 THEN 'New' ELSE '' END AS 'NewReq' ,
CategoryFolderName
FROM Master.Catagory C
Monday, October 14, 2013
Difference between SQL Server 2008 and SQL Server 2012
S.No SQL Server 2008 SQL Server 2012 1 Maximum number of concurrent connections:
The Maximum number of concurrent connections to SQL Server 2008 is 32767.Maximum number of concurrent connections:
SQL server 2012 has unlimited concurrent connections.2 Precision used for spatial calculations:
The SQL Server 2008 uses 27 bit bit precision for spatial calculations.Precision used for spatial calculations:
The SQL Server 2012 uses 48 bit precision for spatial calculations3 TRY_CONVERT() and FORMAT() functions:
TRY_CONVERT() and FORMAT() functions are not available in SQL Server 2008TRY_CONVERT() and FORMAT() functions:
TRY_CONVERT() and FORMAT() functions are newly included in SQL Server 20124 ORDER BY Clause with OFFSET / FETCH options:
ORDER BY Clause does not have OFFSET / FETCH options as in SQL Server 2012ORDER BY Clause with OFFSET / FETCH options:
ORDER BY Clause now have OFFSET / FETCH options to use paging to show required rows per page in applications and allow the user to scroll through each page of results rather than download the entire setIn the sample query below, SQL Server would return 10 records beginning with record 11. The OFFSET command provides a starting point for the SELECT statement in terms of paging, and the FETCH command provides how many records to return at a time.SELECT BusinessEntityID, FirstName, LastNameFROM Person.PersonORDER BY BusinessEntityIDOFFSET 10 ROWSFETCH NEXT 10 ROWS ONLY;5 Code Name:
SQL Server 2008 is code named as Katmai.Code Name:
SQL Server 2012 is code named as DenaliIn SQL Server 2008, audit is an Enterprise-only feature. Only available in Enterprise, Evaluation, and Developer Edition. In SQL Server 2012,support for server auditing is expanded to include all editions of SQL Server. 7 Sequence Object:
Sequence is not available in SQL Server 2008Sequence Object:
Sequence is included in SQL Server 2012.Sequence is a user defined object that generates a sequence of a number.Here is an example using Sequence./****** Create Sequence Object ******/CREATE SEQUENCE MySequenceSTART WITH 1INCREMENT BY 1;/****** Create Temp Table ******/DECLARE @Person TABLE(ID int NOT NULL PRIMARY KEY,FullName nvarchar(100) NOT NULL);/****** Insert Some Data ******/INSERT @Person (ID, FullName)VALUES (NEXT VALUE FOR MySequence, 'Umar Ali'),(NEXT VALUE FOR MySequence, 'John Peter'),(NEXT VALUE FOR MySequence, 'Mohamed Iqbal');/****** Show the Data ******/SELECT * FROM @Person;The results would look like this:ID FullName1 Umar Ali2 John Peter3 Mohamed Iqbal8 Full Text Search Capability:
The Full Text Search in SQL Server 2008 does not allow us to search and index data stored in extended properties or metadata.Full Text Search Capability:
The Full Text Search in SQL Server 2012 has been enhanced by allowing us to search and index data stored in extended properties or metadata. Consider a PDF document that has "properties" filled in like Name, Type, Folder path, Size, Date Created, etc. In the newest release of SQL Server, this data could be indexes and searched along with the data in the document itself. The data does have to be exposed to work, but it's possible now.9 BISM Model:
Analysis Services in SQL Server does not have BI Semantic Model (BISM) concept.BISM Model:
Analysis Services will include a new BI Semantic Model (BISM). BISM is a 3-layer model that includes:Data ModelBusiness LogicData Access
Subscribe to:
Posts (Atom)
Opps Part 1 : Abstraction
Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...
-
exec xp_cmdshell 'net use Z: \\192.01.01.10\FileStorage [Password] /user: 192.01.01.10 \Administrator'(Username) --exec xp_c...
-
<html> <body> <table> <tr><td>Text to Save:</td></tr> <tr> <td colspan="3...
-
MaxDepth – A positive integer that specifies the maximum nested node depth per read. The default value is 32. Maximum is 2147483647. Ma...