"External table is not in the expected format." typically occurs when trying to use an Excel 2007 file with a connection string that uses: Microsoft.Jet.OLEDB.4.0 and Extended Properties=Excel 8.0
Using the following connection string seems to fix most problems.
public static string path = @"C:\src\RedirectApplication\RedirectApplication\301s.xlsx";
public static string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;HDR=Yes;IMEX=1;";
Search This Blog
Friday, August 19, 2011
Print Using Javascript.
function tablePrint(tblId)
{
var display_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
display_setting+="scrollbars=yes,width=750, height=600, left=100, top=25";
var lbtnPrint = document.getElementById('ctl00_CPHVmanage_FvVendorBillEntry_lbtnPrint');
lbtnPrint.style.display = 'none';
var content_innerhtml = document.getElementById(tblId).innerHTML;
var document_print = window.open("","",display_setting);
//document_print.document.open();
document_print.document.write('<html><head><title>Vendor Bill </title></head>');
document_print.document.write('<body onLoad="self.print();self.close();" >');
document_print.document.write(content_innerhtml);
document_print.document.write('</body> //document_print.print();
document_print.document.close();
lbtnPrint.style.display = 'block';
return false;
}
HTML:
<table id="tbl_display" style="text-align:left;" width="100%" cellpadding="2" cellspacing="2" border="0">
<tr>
<td align="left">
<p> Thank you valuable user for signing up.</p>
<p> We think you’ve made a bold decision, and look forward to a productive meeting.</p>
<p> Please print out a copy of this invitation - it will serve as your boarding pass on this tour. </p>
<p> For additional information, you can email <a href="mailto:someone@someone.com">someone@someone.com</a> or call -
xxx-xxx-xxxx, xxx-xxx-xxx and look for Mr. Someone.</p>
</td>
</tr>
</table>
<input type="ctl00_CPHVmanage_FvVendorBillEntry_lbtnPrint" value="Print" onclick="tablePrint('tbl_display');">
{
var display_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
display_setting+="scrollbars=yes,width=750, height=600, left=100, top=25";
var lbtnPrint = document.getElementById('ctl00_CPHVmanage_FvVendorBillEntry_lbtnPrint');
lbtnPrint.style.display = 'none';
var content_innerhtml = document.getElementById(tblId).innerHTML;
var document_print = window.open("","",display_setting);
//document_print.document.open();
document_print.document.write('<html><head><title>Vendor Bill </title></head>');
document_print.document.write('<body onLoad="self.print();self.close();" >');
document_print.document.write(content_innerhtml);
document_print.document.write('</body> //document_print.print();
document_print.document.close();
lbtnPrint.style.display = 'block';
return false;
}
HTML:
<table id="tbl_display" style="text-align:left;" width="100%" cellpadding="2" cellspacing="2" border="0">
<tr>
<td align="left">
<p> Thank you valuable user for signing up.</p>
<p> We think you’ve made a bold decision, and look forward to a productive meeting.</p>
<p> Please print out a copy of this invitation - it will serve as your boarding pass on this tour. </p>
<p> For additional information, you can email <a href="mailto:someone@someone.com">someone@someone.com</a> or call -
xxx-xxx-xxxx, xxx-xxx-xxx and look for Mr. Someone.</p>
</td>
</tr>
</table>
<input type="ctl00_CPHVmanage_FvVendorBillEntry_lbtnPrint" value="Print" onclick="tablePrint('tbl_display');">
Friday, August 12, 2011
Keyword 'this' is not valid in a static property, static method, or static field initialize.
'this' object is not a static property, static method, or static field initialize , so it can not be used to call a static method.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArnoldBaseModule
{
public class Message
{
public static string GetMessage(int ModuleId, int UserId, int AppId, int ConAppId, bool Successed, int indicator)
{
if (Successed)
{
this.GenerateMessage(ModuleId, UserId, AppId, ConAppId, Successed, indicator);
//Use below line without 'this' to call a methos instead of above............
GenerateMessage(ModuleId, UserId, AppId, ConAppId, Successed, indicator);
}
return "";
}
private static string GenerateMessage(int ModuleId, int UserId, int AppId, int ConAppId, bool Successed, int indicator)
{
return "";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArnoldBaseModule
{
public class Message
{
public static string GetMessage(int ModuleId, int UserId, int AppId, int ConAppId, bool Successed, int indicator)
{
if (Successed)
{
this.GenerateMessage(ModuleId, UserId, AppId, ConAppId, Successed, indicator);
//Use below line without 'this' to call a methos instead of above............
GenerateMessage(ModuleId, UserId, AppId, ConAppId, Successed, indicator);
}
return "";
}
private static string GenerateMessage(int ModuleId, int UserId, int AppId, int ConAppId, bool Successed, int indicator)
{
return "";
}
}
}
SqlConnection.ConnectionTimeout Property.
Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)
Type: System.Int32
The time (in seconds) to wait for a connection to open. The default value is 15 seconds.
Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)
Type: System.Int32
The time (in seconds) to wait for a connection to open. The default value is 15 seconds.
SqlCommand.CommandTimeout Property.
Property Value
Type: System.Int32
The time in seconds to wait for the command to execute. The default is 30 seconds.
Type: System.Int32
The time in seconds to wait for the command to execute. The default is 30 seconds.
Saturday, August 6, 2011
How to show div on mousehover?
Javascript Part:
<script type="text/javascript">
function Show(id) {
var div1 = document.getElementById("MainContent_div1");
div1.style.display = "block";
var ev = window.event;
var x = ev.clientX;//mouse position from left
var y = ev.clientY;//mouse position from top
div1.style.left = x;
div1.style.top = y;
}
function Hide(id) {
var div1 = document.getElementById("MainContent_div1");
div1.style.display = "none";
}
</script>
html part
<span id="MainContent_lbl1" onmouseover="javascript:Show(this);">Test <div id="MainContent_div1" style="position: absolute; z-index: 999; display: none;">
<table bgcolor="blue">
<tr>
<td>
<input name="ctl00$MainContent$txt1" type="text" id="MainContent_txt1" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox1" type="text" id="MainContent_TextBox1" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox2" type="text" id="MainContent_TextBox2" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox3" type="text" id="MainContent_TextBox3" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox4" type="text" id="MainContent_TextBox4" />
</td>
</tr>
<tr>
<td>
<input type="submit" name="ctl00$MainContent$btn1" value="Close" onclick="javascript:Hide(this);return false;" id="MainContent_btn1" />
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function Show(id) {
var div1 = document.getElementById("MainContent_div1");
div1.style.display = "block";
var ev = window.event;
var x = ev.clientX;//mouse position from left
var y = ev.clientY;//mouse position from top
div1.style.left = x;
div1.style.top = y;
}
function Hide(id) {
var div1 = document.getElementById("MainContent_div1");
div1.style.display = "none";
}
</script>
html part
<span id="MainContent_lbl1" onmouseover="javascript:Show(this);">Test <div id="MainContent_div1" style="position: absolute; z-index: 999; display: none;">
<table bgcolor="blue">
<tr>
<td>
<input name="ctl00$MainContent$txt1" type="text" id="MainContent_txt1" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox1" type="text" id="MainContent_TextBox1" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox2" type="text" id="MainContent_TextBox2" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox3" type="text" id="MainContent_TextBox3" />
</td>
</tr>
<tr>
<td>
<input name="ctl00$MainContent$TextBox4" type="text" id="MainContent_TextBox4" />
</td>
</tr>
<tr>
<td>
<input type="submit" name="ctl00$MainContent$btn1" value="Close" onclick="javascript:Hide(this);return false;" id="MainContent_btn1" />
</td>
</tr>
</table>
</div>
Friday, August 5, 2011
How to use Container.DataItemIndex?
<asp:GridView ID="gvVendorBillDtl" runat="server" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false" Width="100%" CellPadding="2" CellSpacing="0" BorderWidth="1" PageSize="5"
<Columns>
<asp:TemplateField HeaderText="Sr.No.">
<ItemTemplate>
<asp:Label ID="SrNo" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<Columns>
<asp:TemplateField HeaderText="Sr.No.">
<ItemTemplate>
<asp:Label ID="SrNo" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Subscribe to:
Posts (Atom)