The ‘System.Web.Security.SqlMembershipProvider’ requires a database schema compatible with schema version ’1′.
I figured out the problem though and it was a typical bonehead mistake. I used a script to recreate all the tables for Membership. I didn't copy any data into those tables. There is a table called aspnet_schemaversions. It requires some values to be able to validate the versions (duh). When I added these values into the table, it started working.
common 1 1
health monitoring 1 1
membership 1 1
personalization 1 1
profile 1 1
role manager 1 1
Chalk it up to the learning curve!
C#操作Word完全功略!
前提:
导入COM库:Microsoft word 11.0 Object Library.
引用里面就增加了:
创建新Word
打开文档:
导入模板
.添加新表
.表插入行
.单元格合并
.单元格分离
通过段落控制插入
C#利用word书签实现模板打印功能
C#中的水晶报表好用,但是需要注册码。这里介绍C#调用word直接打印,既方便,又漂亮。
开发指南:
1. 必须安装office的.net开发包。
2. 在工程的reference中添加com组件:Microsoft Word 11.0 Object Library
打印的代码如下:
Microsoft.Office.Interop.Word.Application app = null;
Microsoft.Office.Interop.Word.Document doc = null;
object missing = System.Reflection.Missing.Value;
object templateFile = Application.StartupPath + @"表单模版.doc";
try
{
app = new Microsoft.Office.Interop.Word.ApplicationClass();
doc = app.Documents.Add(ref templateFile, ref missing, ref missing, ref missing);
try
{
foreach (Microsoft.Office.Interop.Word.Bookmark bm in doc.Bookmarks)
{
bm.Select();
string item = bm.Name;
if (item.Equals("in_time"))
{
bm.Range.Text = table.inTime == null ? "" : table.inTime.ToString();
}
else if (item.Equals("car_id"))
{
bm.Range.Text = table.carID == null ? "" : table.carID.ToString();
}
}
}
catch
{
}
//打印
doc.PrintOut(ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message, this.Text);
}
//销毁word进程
finally
{
object saveChange = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
if (doc != null)
doc.Close(ref saveChange, ref missing, ref missing);
if (app != null)
app.Quit(ref missing, ref missing, ref missing);
}
C#用 excel 作为模板打印的源码
源码
/*
' //-*****************************************************-//
' // 如果您要献一份爱心,请参预希望工程! //
' // 如果您还支持作者,请联系作者! //
'//-*****************************************************-//
'
' /// 作 者:长江支流(周方勇)
' /// Email:MisGoldPrinter@163.com QQ:150439795
' /// 网 址:www.webmis.com.cn
' /// ★★★★★您可以免费使用此程序,但是请您完整保留此说明,以维护知识产权★★★★★
'
*/
//打印操作,套打、打印、预览
enum PrintFlag
{
/// <summary>
/// 套打,只打印没有印刷的部分
/// </summary>
CasePrint,
/// <summary>
/// 打印全部
/// </summary>
PrintAll,
/// <summary>
/// 预览全部
/// </summary>
PreviewAll
}
//套打、打印、预览三个按钮关联些委托实例
private void Print_Click(object sender, System.EventArgs e)
{
Button btn = (Button)sender;
switch(btn.Tag.ToString())
{
case "套打":
Print(PrintFlag.CasePrint);
break;
case "打印":
Print(PrintFlag.PrintAll);
break;
case "预览":
Print(PrintFlag.PreviewAll);
break;
}
}
private void Print(PrintFlag p_printFlag)
{
//制作步骤:
/* 1、用Excel作出与要打印的样式一样的电子表格存为模板;
* 技巧:最好把第一行与第一列作为空行,以利于调整边距(虽然Excel、打印机可调整页边距), 尽量的在需要调整的地方多空几行与几列,以利于调整套打对准
*
* 2、如同本程序一样,将Excel作为套打的模板,直接将要打印的数据写入;
*
* 3、打印,根据实际的效果调整Excel模板行高列宽及空出的行列, 直到能够准确的套上。将模板拷贝一份,清除模板上的文字与网格线,做成套打的模板。
*/
#region 套打、打印预览
//用Excel打印,步骤为:打开、写数据、打印预览、关闭
GoldPrinter.ExcelExpert.ExcelBase excel = new GoldPrinter.ExcelExpert.ExcelBase();
string strFileName = "invoice.xlt"; //模板文件名
if (p_printFlag == PrintFlag.CasePrint)
{
strFileName = "invoiceCase.xlt"; //套打模板文件名
}
string strExcelTemplateFile = System.IO.Path.GetFullPath(@"....ExcelTemplate" + strFileName);
excel.Open(strExcelTemplateFile); // 用模板文件
excel.Visible = false; //建议:如果excel不可见且在编程情况下写数据特 别是大量数据时
excel.ScreenUpdating = false; //设置此开关能大大提高效率。写完后如要可见,再设置此属性为真刷新屏 幕。
excel.Caption = "税 务 机 关 代 开 统 一 发 票(国 税)"; //"MIS金质打印通 通打天下报表";
//在模板中写入要打印的数据
//***发票抬头***
//年月日
excel.SetCellText(7,"B",txtYear.Text + "年" + txtMonth.Text + "月" + txtDay.Text + "日" );
//付款方名称
excel.SetCellText(8,"D",txtPayer.Text);
//收款方名称
excel.SetCellText(9,"D",txtCollecter.Text);
//及地址、电话
excel.SetCellText(11,"D",txtCollecterAddTel.Text);
// 代开普通发票 申 请 表 号 码
excel.SetCellText(8,"J",txtInvoiceApplicationNo.Text);
//收款方识别号或 证 件 号 码
excel.SetCellText(9,"J",txtCollecterID.Text);
//***品名及金额、备注***
//B14到B23是品名 F14到F23为金额
excel.SetCellText("B14",txtP1.Text);
excel.SetCellText("F14",txtJ1.Text);
excel.SetCellText("B15",txtP2.Text);
excel.SetCellText("F15",txtJ2.Text);
excel.SetCellText("B16",txtP3.Text);
excel.SetCellText("F16",txtJ3.Text);
excel.SetCellText("B17",txtP4.Text);
excel.SetCellText("F17",txtJ4.Text);
excel.SetCellText("B18",txtP5.Text);
excel.SetCellText("F18",txtJ5.Text);
excel.SetCellText("B19",txtP6.Text);
excel.SetCellText("F19",txtJ6.Text);
excel.SetCellText("B20",txtP7.Text);
excel.SetCellText("F20",txtJ7.Text);
excel.SetCellText("B21",txtP8.Text);
excel.SetCellText("F21",txtJ8.Text);
excel.SetCellText("B22",txtP9.Text);
excel.SetCellText("F22",txtJ9.Text);
excel.SetCellText("B23",txtP10.Text);
excel.SetCellText("F23",txtJ10.Text);
//备注
//excel.SetCellText(14,"I",txtMemo.Imag.);
//***发票总金额***
//合计人民币 (大写)
excel.SetCellText(24,"D",txtTotalUpper.Text);
//合计人民币 (小写)
excel.SetCellText(24,"K",txtTotalLower.Text);
//税额 (大写)
excel.SetCellText(25,"D",txtTaxUpper.Text);
//税额 (小写)
excel.SetCellText(25,"L",txtTaxLower.Text);
//***发票尾***
//税控码
excel.SetCellText(26,"C",txtTaxControlCode.Text);
//开票人:
excel.SetCellText(26,"H",txtWriter.Text);
//刷新Excel屏幕
excel.ScreenUpdating = true;
if (p_printFlag == PrintFlag.CasePrint || p_printFlag == PrintFlag.PrintAll)
{
excel.Print(); //打印
}
else
{
excel.PrintPreview(); //预览
}
excel.Close(); //关闭并释放
#endregion
}
private void frmInvoice_Load(object sender, System.EventArgs e)
{
//初始当日日期
System.DateTime dt = System.DateTime.Now;
SetToday(dt);
}
private void btnExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
//回车
private void frmInvoice_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
SendKeys.Send("{TAB}");
}
}
//金额小写转人民币大写
private void txtTotalLower_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
SetUpperMoney();
}
//重新总计
private void txtJX_TextChanged(object sender, System.EventArgs e)
{
double dblMoney = 0;
dblMoney += GetInputMoney(txtJ1.Text);
dblMoney += GetInputMoney(txtJ2.Text);
dblMoney += GetInputMoney(txtJ3.Text);
dblMoney += GetInputMoney(txtJ4.Text);
dblMoney += GetInputMoney(txtJ5.Text);
dblMoney += GetInputMoney(txtJ6.Text);
dblMoney += GetInputMoney(txtJ7.Text);
dblMoney += GetInputMoney(txtJ8.Text);
dblMoney += GetInputMoney(txtJ9.Text);
dblMoney += GetInputMoney(txtJ10.Text);
txtTotalLower.Text = dblMoney.ToString();
SetUpperMoney();
}
//改变税率重算
private void cboTaxRate_TextChanged(object sender, System.EventArgs e)
{
SetUpperMoney();
}
private void btnRefDate_Click(object sender, System.EventArgs e)
{
cldSelect.Visible = true;
cldSelect.SetDate(new DateTime(int.Parse(txtYear.Text),int.Parse(txtMonth.Text),int.Parse(txtDay.Text)));
cldSelect.Focus();
}
private void cldSelect_DateSelected(object sender, System.Windows.Forms.DateRangeEventArgs e)
{
SetToday(e.End);
cldSelect.Visible = false;
}
//大写合计人民币、税额
private void SetUpperMoney()
{
try
{
// string strUpper = GoldPrinter.ExcelExpert.ChineseNum.GetUpperMoney(Double.Parse(txtTotalLower.Text));
// //合计人民币
// txtTotalUpper.Text = strUpper;
//
// strUpper = GoldPrinter.ExcelExpert.ChineseNum.GetUpperMoney(Double.Parse(txtTotalLower.Text) * Double.Parse(cboTaxRate.Text) / 100);
// //税额 = 合计人民币 * 税率
// txtTaxUpper.Text = strUpper;
}
catch{}
}
private double GetInputMoney(string p_text)
{
double dblReturn = 0;
try
{
dblReturn = double.Parse(p_text);
}
catch{}
return dblReturn;
}
private void SetToday(System.DateTime dt)
{
txtYear.Text = dt.Year.ToString();
txtMonth.Text = GetLengthTwoDate(dt.Month.ToString());
txtDay.Text = GetLengthTwoDate(dt.Day.ToString());
}
private string GetLengthTwoDate(string p_MonthOrDay)
{
string strReturn = p_MonthOrDay;
if (strReturn.Length == 1)
{
strReturn = "0" + strReturn;
}
return strReturn;
}
}//End Class
}//End Namespace
C#调用QQ的DLL实现截图功能
今天写个程序 需要抓屏 懒得写代码 上网找
突然想到QQ的抓屏不错 直接拿来用就是了
[ DllImport( "CameraDll.dll", EntryPoint="CameraSubArea", CharSet=CharSet.Ansi )]
private static extern bool CameraSubArea();
if(CameraSubArea())
{
IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();
if(iData.GetDataPresent("System.Drawing.Bitmap",true))
{
this.pictureBox1.Image=iData.GetData("System.Drawing.Bitmap") as Bitmap;
}
}
