English 中文(简体)
• 如何利用与ACESS DB的联系填写电网表
原标题:How can I fill a gridview using a connection to a ACCESS DB

我如何使用访问数据库链接,填满<>GridView?

到目前为止,我有以下法典:

OleDbConnection myConnection = default(OleDbConnection);
OleDbCommand myCommand = default(OleDbCommand);
string strSQL = null;
strSQL = "SELECT * FROM tblLoginInfo " + "WHERE username= " + CustID.Replace(" ", "  ") + "  " + "AND password= " + CustPass.Replace(" ", "  ") + " ;";
myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=" + Server.MapPath("login.mdb") + ";");

myCommand = new OleDbCommand(strSQL, myConnection);
myConnection.Open();

但现在情况如何?

最佳回答
 OleDbConnection myConnection = default(OleDbConnection);
         OleDbCommand myCommand = default(OleDbCommand);
         string strSQL = null;
         strSQL = "SELECT * FROM tblLoginInfo " + "WHERE username= " + CustID.Replace(" ", "  ") + "  " + "AND password= " +
 CustPass.Replace(" ", "  ") + " ;";
         myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source="
 + Server.MapPath("login.mdb") + ";");
        myConnection.Open();
         myCommand = new OleDbCommand(strSQL, myConnection);

         OleDbDataAdapter adp=new OledbDataAdapter(myCommand);
         dataset ds=new dataset();
         adp.fill(ds);
        gridview.datasource=ds;
        gridview.databind();
问题回答

类似情况

        <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
            DataFile="~/App_Data/AccesFile.mdb" SelectCommand="SELECT * FROM [TableName]">
        </asp:AccessDataSource>
        <asp:GridView ID="GridView1" runat="server" DataSourceID="AccessDataSource1">
        </asp:GridView>

http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-linking-to-Access-databases-in-ASP.NET“rel=” AccessDataSource, SqlDataSource andlinking to Access database in ASP. NET

我还认为,该条涉及

希望这一帮助





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签