解决方案 »
- 问个低级问题,不要见笑!Discuz!NT源码怎么用?
- AjaxPro 问题
- 请教我用VS2005做了两个网站,现在服务器只有一个空间,怎么放到一起去?
- 如何把columns集合转换成DataColumn[]数组
- 编程方式绑定dropdownlist
- 微软的asp.net快速入门中示例程序关系到数据库不能打开怎么办??
- 在工具箱里的 RadioButtonList 每行只有一个,能不能平躺下来啊?
- 求救:FreeTextBox 3.0传到虚拟主机上无法正确显示?
- 在vs.net上做的ASP。ENT程序为什么发布到WIN2003上就无法显示///急!!
- datagrid中,如何得到总的 记录数?
- repeater实现统计问题
- 怎么不用自动绑定。在Click事件中绑定GridView的值。急急急!!!
{
conn.Open();
SqlCommand MyCommand = new SqlCommand("MYSQL", conn);
MyCommand.CommandType = CommandType.StoredProcedure;
...
}
检查连接字符串
{
using(SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ToString()))
{
conn.Open();
SqlCommand MyCommand = new SqlCommand("MYSQL", conn);
MyCommand.CommandType = CommandType.StoredProcedure;
...
}...
}
1、应输入类型、命名空间定义或文件尾
2、Type or namespace definition or end-of-file expected
该怎么办呢???
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;/// <summary>
/// Summary description for Class1
/// </summary>
public class FileDB
{
public FileDB()
{}
public static string SQLCONNECTIONSTRING = ConfigurationSettings.AppSettings["SQLCONNECTIONSTRING"].ToString();
public SqlDataReader GetFiles()
{
using(SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ToString()))
{
conn.Open();
SqlConnection myCommand=new SqlCommand("Pr_GetFiles",myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlDataReader dr=null;
try{ myConnection.Open();}
catch (Exception ex) { throw new Exception("数据库连接失败!",ex);}
try
{
dr=myCommand.ExecuteReader(CommandBehavior.CloseConnection);
}
catch(Exception ex){throw new Exception(ex.Message,ex);}
return(dr);
}
}
public int AddFile(String sFileName,String sFileUrl,String sFileKind)
{
SqlConnection myConnection=new SqlConnection(SQLCONNECTIONSTRING);
SqlCommand myCommand=new SqlCommand("Pr_AddFile",myConnection);
SqlParameter parameterFileID=new SqlParameter("@FileID",SqlDbType.Int,4);
parameterFileID.Direction=ParameterDirection.ReturnValue;
myCommand.Parameters.Add(parameterFileID);
try{myConnection.Open();}
catch(Exception ex){throw new Exception("数据库连接失败!",ex);}
try{myCommand.ExecuteNonQuery();}
catch(Exception ex){throw new Exception(ex.Message,ex);}
return(int)parameterFileID.Value;
}
//
// TODO: Add constructor logic here
//
}
改成这样之后报错说找不到类型或命名空间名称“SqlDataReader”(是否缺少 using 指令或程序集引用?)
1、无法将类型“System.Data.SqlClient.SqlCommand"隐式转换为“System.Data.SqlClient.SqlConnection"
2、“System.Data.SqlClient.SqlConnection"不包含“commandType"的定义,并且找不到可接受类型为“System.Data.SqlClient.SqlConnection"的第一个参数的扩展方法“commandType"(是否缺少 using 指令或程序集引用?)3、、“System.Data.SqlClient.SqlConnection"不包含“ExecuteReader"的定义,并且找不到可接受类型为“System.Data.SqlClient.SqlConnection"的第一个参数的扩展方法“ExecuteReader"(是否缺少 using 指令或程序集引用?)
MyCommand.CommandType = CommandType.StoredProcedure;MyCommand.ExecuteReader();
if (File.Exists(Server.MapPath(Request.ApplicationPath) + "\\UpLoads" + fileName) == false)
说是当前上下文中不存在名称File。真是命途多舛啊