Tag Archives: data
using excel datasource to load data in c#
<%@ Page Language="C#" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server"> void Page_Load(object sender, EventArgs e) { string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\myspreadsheet.xls; Extended Properties=""Excel 8.0;HDR=Yes"";"; string CommandText = "select * from [Book$]"; OleDbConnection myConnection = new … Continue reading
Terminate the ability to send or receive data using the Socket.Shutdown method in C#
using System; using System.Net; using System.Net.Sockets; using System.Text; public class SocketShutdownSample { public static void Main() { IPAddress ip = IPAddress.Parse("127.0.0.1"); string targ = "/default.htm"; Socket skt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { IPEndPoint ep = new IPEndPoint(ip, 80); … Continue reading
How to control the transfer behavior when sending and receiving data on a Socket instance in C#
We can use the System.Net.Sockets SocketFlags Enumeration to control the transfer behavior when sending and receiving data on a Socket instance in C#. using System; using System.Net; using System.Net.Sockets; using System.Text; public class SocketFlagsSample { public static void Main() { … Continue reading
Socket class to send data and receive the response
The Socket class creates a managed version of an Internet transport service. Once the Socket is created, the Socket is bound to a specific endpoint through the Socket.Bind method, and the connection to that endpoint is established through the Socket.Connect … Continue reading
Request and Display Basic Viewer Data in Open Social
Step 1. Request data: a. Create DataRequest object by calling opensocial.newDataRequest. b. For each request you wish to make, create it using one of the opensocial.new* methods. c. For each piece of data you want to request, add a request … Continue reading
Read data from SQL server and convert it to XML in C#
Example code to Read data from SQL server and convert it to XML: using System; using System.Data; using System.Xml; using System.Data.SqlClient; using System.IO; public class TestWriteXML { public static void Main() { String strFileName = c:/temp/out.xml; SqlConnection conn = … Continue reading
Read file up to 1024 bytes of data in csharp
Stream stream = File.OpenRead(@"C:\data\file.xml"); int bytesToRead = 1024; int bytesRead = 0; byte [ ] buffer = new byte [bytesToRead]; // Fill up the buffer repeatedly until we reach the end of file do { bytesRead = stream.Read(buffer, 0, … Continue reading
How MVC returns data to browser
The MVC is a design pattern and stands for model-view-controller. When there is no need to fetch data from the database, only the View is called, and loaded by the Controller. Then it is returned to the browser for rendering. … Continue reading