Hi,
Here is the query to export the data from Excel to sqlserver
INSERT INTO [dbo].[Address_Temp] ( [FirstName], [LastName], [Address], [City], [State], [ZIP] )
SELECT [FirstName], [LastName], [Address], [City], [State], [ZIP]
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Source\Addresses.xls;IMEX=1',
'SELECT * FROM [Sheet1$]')
To Access the function such as OPENROWSET Go to
MicroSoftSqlServer2005--->ConfigurationTools--->
SqlSurfaceAreaConfiguration
Click on Surface Area Configuration For features
and Enable OPENROWSET and OPENDATASOURCE support
Monday, December 21, 2009
Monday, November 10, 2008
Post method of form data handling by request object
In POST method of sending form data to processing page is more used than GET method. In POST method data entered inside the form is passed to action page by using HTTP header. The main difference visible here is that data is not passed through URL as a query string in user address bar (like GET method). Here is the form code for method object.
we can transfer our data like this,
HttpWebRequest request = null;
request = (HttpWebRequest)HttpWebRequest.Create("http://localhost/Default.aspx?");
request.KeepAlive = true;
request.Method = "POST";
string postData = "ID=" + 1 + "&RegKey=" + 2;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
//request.ContentType = "text/xml";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
Like in the Get method we can also loop through and display all the name value pairs associated in POST method of form submission. Here is the code
Collecting data using Request object
Eg,
string id = Request.Form.Get("ID");
string regKey = Request.Form.Get("RegKey");
we can transfer our data like this,
HttpWebRequest request = null;
request = (HttpWebRequest)HttpWebRequest.Create("http://localhost/Default.aspx?");
request.KeepAlive = true;
request.Method = "POST";
string postData = "ID=" + 1 + "&RegKey=" + 2;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
//request.ContentType = "text/xml";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
Like in the Get method we can also loop through and display all the name value pairs associated in POST method of form submission. Here is the code
Collecting data using Request object
Eg,
string id = Request.Form.Get("ID");
string regKey = Request.Form.Get("RegKey");
Get method and request object to collect data
In GET method data of the form is passed through query string in name and value pairs. The data is separated from the file name by question mark( ? ) and between each pare of name and value ampersand ( & ) symbol is used to separate. Here is the example how in the GET method data is transferred.
http://www.plus2net.com/file_name.asp?name=john&country=USA&age=10
You can see in the above query string the form data is kept after the file name and the question mark ( ? ) . Then name and value pairs are used and they are separated by ampersand ( & ). This is the way data is posted using URL or the address bar of the browser window.
Collecting data using Request object
Once the form is submitted data is available to the page indicated at the action attribute of the form. Here we have to use Request.QueryString to get the value of the data field. To get the name entered by the user in name field here is the code
Eg,
string name = "";
name=Request.QueryString.get("name");
http://www.plus2net.com/file_name.asp?name=john&country=USA&age=10
You can see in the above query string the form data is kept after the file name and the question mark ( ? ) . Then name and value pairs are used and they are separated by ampersand ( & ). This is the way data is posted using URL or the address bar of the browser window.
Collecting data using Request object
Once the form is submitted data is available to the page indicated at the action attribute of the form. Here we have to use Request.QueryString to get the value of the data field. To get the name entered by the user in name field here is the code
Eg,
string name = "";
name=Request.QueryString.get("name");
Difference in GET and FORM method in posting data
We can send data to the data processing page by both the GET and POST methods of a form. Both methods are used in form data handling where each one has some difference on the way they work. We will discuss some of the differences.
As you have seen there is a character restriction of 255 in the URL. This is mostly the old browsers restriction and new ones can handle more than that. But we can't be sure that all our visitors are using new browsers. So when we show a text area or a text box asking users to enter some data, then there will be a problem if more data is entered. This restriction is not there in POST method.
In GET method data gets transferred to the processing page in name value pairs through URL, so it is exposed and can be easily traced by visiting history pages of the browser. So any login details with password should never be posted by using GET method.
As the data transfers through address bar ( URL ) there are some restrictions in using space, some characters like ampersand ( & ) etc in the GET method of posting data. We have to take special care for encoding ( while sending ) and decoding ( while receiving ) data if such special characters are present.
There are some special cases where advantage of using GET method is , one can store the name value pairs as bookmark and directly use them by bypassing the form.
As you have seen there is a character restriction of 255 in the URL. This is mostly the old browsers restriction and new ones can handle more than that. But we can't be sure that all our visitors are using new browsers. So when we show a text area or a text box asking users to enter some data, then there will be a problem if more data is entered. This restriction is not there in POST method.
In GET method data gets transferred to the processing page in name value pairs through URL, so it is exposed and can be easily traced by visiting history pages of the browser. So any login details with password should never be posted by using GET method.
As the data transfers through address bar ( URL ) there are some restrictions in using space, some characters like ampersand ( & ) etc in the GET method of posting data. We have to take special care for encoding ( while sending ) and decoding ( while receiving ) data if such special characters are present.
There are some special cases where advantage of using GET method is , one can store the name value pairs as bookmark and directly use them by bypassing the form.
Wednesday, September 10, 2008
Difference between Server.Transfer and Response.Redirect
Difference between Server.Transfer and Response.Redirect
Why would I choose one over the other?
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user's browser to another page or site. This perform as a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.
Why would I choose one over the other?
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user's browser to another page or site. This perform as a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.
Some .net tips....
Difference between Response.Write() and Response.Output.Write()...
Response.Output.Write() allows you to write formatted output.
Methods are fired during the page load...
Init() - when the page is instantiated
Load() - when the page is loaded into server memory
PreRender() - the brief moment before the page is displayed to the user as HTML
Unload() - when page finishes loading.
Difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs "...
CodeBehind is relevant to Visual Studio.NET only.
Response.Output.Write() allows you to write formatted output.
Methods are fired during the page load...
Init() - when the page is instantiated
Load() - when the page is loaded into server memory
PreRender() - the brief moment before the page is displayed to the user as HTML
Unload() - when page finishes loading.
Difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs "...
CodeBehind is relevant to Visual Studio.NET only.
Data types supported by RangeValidator
The following data types are supported for RangeValidator control
Integer, String, and Date.
Integer, String, and Date.
Subscribe to:
Posts (Atom)