日期:2014-05-20  浏览次数:20547 次

执行SQL语句问题
页面内容lx2.aspx.cs

using   System;
using   System.Data;
using   System.Configuration;
using   System.Collections;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;
using   System.Data.SqlClient;
using   System.Data.OleDb;
public   partial   class   lx2   :   System.Web.UI.Page
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                string   connStr   =   System.Configuration.ConfigurationSettings.AppSettings[ "connString "];


                OleDbConnection   myConnection   =   new   OleDbConnection(connStr);
                myConnection.Open();

                        string   queryStr   =   "select   *   from   [DA] ";
                       
        26行             SqlCommand   myCommand   =   new   SqlCommand(queryStr,   myConnection);


        }

}


错误提示:
编译器错误信息:   CS1502:   与“System.Data.SqlClient.SqlCommand.SqlCommand(string,   System.Data.SqlClient.SqlConnection)”最匹配的重载方法具有一些无效参数

错误行数:26行

------解决方案--------------------
OleDbConnection myConnection = new OleDbConnection(connStr);
改成:
SqlConnection myConnection = new SqlConnection(connStr);