using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Text.RegularExpressions;
namespace WareHouseManagementSystems
{
class connection
{
public SqlConnection con = new SqlConnection();
public SqlCommand com = new SqlCommand();
public SqlDataReader dr;
public void connect()
{
try
{
con.ConnectionString ="Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\WAREHOUSEMANAGEMENTSYSTEMS_VS2008\\WAREHOUSEMANAGE MENTSYSTEMS_VS2008\\DATABASE\\2008\\WAREHOUSEMANAGEMENT.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True";
con.Open();
com.Connection = con;
com.CommandType = CommandType.Text;
}
catch
{
}
}
public bool isValidEmail(string inputEmail)
{
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
}
}
每当我调试它,我得到一个错误说 的ExecuteReader:连接属性未初始化! 我试着检查连接路径一切都改变到所需的路径或位置。但一切都是徒劳。我很感激,如果ne1 culd帮助我发现错误 我迫切需要提交我的项目,所以我会很感激,如果有人帮助我!的ExecuteReader:连接属性未初始化错误VS 2010
,真的是这样你的代码的格式?我不希望如此。请在您的文章中格式化代码,以便阅读。另外,你真的有一个空的catch块吗?这意味着当你打开连接时你看不到任何错误 - 这可能是问题所在...... –
看到调用ExecuteReader的代码也很有用。 – Steve
另外,摆脱那个try/catch块。将代码保存在try中,但是要去掉这个块 - 你忽略了异常。 –