Answered by:
ASP.net using password protected Access2003 data

Question
-
User-2024981698 posted
Sir,
I am using two database on is SQL Server and one is Access2003 in my asp.net application but even after correct data password I am getting error for access database as incorrect password . Pl. help it is urgent I am not solution any where .
aspx file <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> <table class="style2" __designer:mapid="2c"> <tr __designer:mapid="2d"> <td class="style6" __designer:mapid="2e"> </td> <td class="style5" __designer:mapid="2f"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:SqlDataSource ID="firmsql" runat="server" ConnectionString="<%$ ConnectionStrings:accountsConnectionString %>" SelectCommand="SELECT
, [NAME] FROM [FIRM] ORDER BY [NAME]"> </asp:SqlDataSource> </td> </tr> <tr __designer:mapid="33"> <td class="style16" __designer:mapid="34"> </td> <td class="style15" __designer:mapid="35"> Statement of Periodical Income and Expenditure </td> </tr> <tr __designer:mapid="33"> <td class="style12" __designer:mapid="34"> Period </td> <td class="style13" __designer:mapid="35"> <asp:TextBox ID="st_date" runat="server"></asp:TextBox> <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="ST_DATE"> </asp:CalendarExtender> To <asp:TextBox ID="end_date" runat="server"></asp:TextBox><asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="END_DATE"> </asp:CalendarExtender> <asp:Button ID="cmdAllheads" runat="server" Text="All Heads" Height="20px" Width="126px" /> </td> </tr> <tr __designer:mapid="33"> <td class="style14" __designer:mapid="34"> </td> <td class="style3" __designer:mapid="35"> Income </td> </tr> <tr __designer:mapid="33"> <td class="style9" __designer:mapid="34"> </td> <td class="style10" __designer:mapid="35"> <asp:GridView ID="gridincome" runat="server" AutoGenerateColumns="False" DataSourceID="accessinc" > <Columns> <asp:BoundField DataField="SNO" HeaderText="SNO" SortExpression="SNO" /> <asp:BoundField DataField="TR_MONTH" HeaderText="TR_MONTH" SortExpression="TR_MONTH" /> <asp:BoundField DataField="TR_YEAR" HeaderText="TR_YEAR" SortExpression="TR_YEAR" /> <asp:BoundField DataField="TR_DATE" HeaderText="TR_DATE" SortExpression="TR_DATE" /> <asp:BoundField DataField="MIN_HEAD_NAME" HeaderText="MIN_HEAD_NAME" SortExpression="MIN_HEAD_NAME" /> <asp:BoundField DataField="AMOUNT" HeaderText="AMOUNT" SortExpression="AMOUNT" /> </Columns> </asp:GridView> <asp:AccessDataSource ID="accessinc" runat="server" DataFile="d:\modata\incexp.mdb" SelectCommand="SELECT * FROM [ACCREDITIONFEE_TRANSACN]"> </asp:AccessDataSource> </td> </tr> <tr __designer:mapid="3c"> <td class="style7" __designer:mapid="3d" colspan="2"> <asp:GridView ID="GridView1" runat="server" AutoGenerateSelectButton="True" BorderStyle="Solid" Caption="Budget Head Total Expenditure for Period" CellSpacing="1" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Size="Larger" Width="745px" Height="205px" ForeColor="Black"> <HeaderStyle BackColor="#CCCCFF" BorderColor="Black" BorderWidth="2px" /> </asp:GridView> </td> </tr> <tr __designer:mapid="3c"> <td class="style11" __designer:mapid="3d"> </td> <td class="style8" __designer:mapid="3e"> </td> </tr> </table> <br />
VB code
Protected Sub cmdAllheads_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAllheads.Click Dim stdate, enddate As Date Dim dt As DateTime = DateTime.Parse(st_date.Text, System.Globalization.CultureInfo.GetCultureInfo("en-us")) stdate = Convert.ToDateTime(dt.ToShortDateString()) Dim dt1 As DateTime = DateTime.Parse(end_date.Text, System.Globalization.CultureInfo.GetCultureInfo("en-us")) enddate = Convert.ToDateTime(dt1.ToShortDateString()) Dim SqlDataSource1 As New SqlDataSource() SqlDataSource1.ID = "sqlfirmdt" Me.Page.Controls.Add(SqlDataSource1) SqlDataSource1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("accountsConnectionString").ConnectionString 'SqlDataSource1.SelectCommand = "select a.name,b.code,A.BUDGET as Budget,b.amount AS Expense,A.BUDGET-B.AMOUNT AS Balance from exphead a,(select code,sum(amount) as Amount from exp where cast(CONVERT(varchar(8), date, 112) AS datetime) between '" & stdate & "' and '" & enddate & "' AND TYPE NOT IN('ARL','SL','FRESH') group by code) b where a.code=b.code order by a.name " SqlDataSource1.SelectCommand = "select * from (select a.name,a.code,b.amount AS Expense from exphead a left join (select code,sum(amount) as Amount from exp where cast(CONVERT(varchar(8), date, 112) AS datetime) between '" & stdate & "' and '" & enddate & "' AND TYPE NOT IN('ARL','SL','FRESH') group by code) b on a.code=b.code ) a where expense <> 0 order by a.name " GridView1.DataSource = SqlDataSource1 GridView1.DataBind() Dim sqldatasource2 As New SqlDataSource sqldatasource2.ID = "sqlincexp" SqlDataSource1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("incexpConnectionString").ConnectionString sqldatasource2.SelectCommand = " SELECT min_head_name, sum(amount) FROM(examinationfee_TRANSACN) WHERE tr_date between #" & stdate & " # and #" & enddate & " # GROUP BY min_head_name " Me.gridincome.DataSource = sqldatasource2 gridincome.DataBind() End Sub
web.config file
<add name="accountsConnectionString" connectionString="Data Source=CASHSRV\SQLEXPRESS;Initial Catalog=accounts;User ID=sa;Password=saadmin; MultipleActiveResultSets=true" providerName="System.Data.SqlClient" /> <add name="incexpConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\modata\incexp.mdb;Persist Security Info=True;Jet OLEDB:Database Password=seeanu" providerName="System.Data.OleDb" />
Friday, May 6, 2016 8:01 AM
Answers
-
User-18289217 posted
I've created an Access database containing a table with the same structure and i was able to load the foo data into the gridview with identical columns/fields
this is how do i bind the gridview ...
Private Sub Rebind() Using connection As New OleDb.OleDbConnection( ConfigurationManager.ConnectionStrings("incexpConnectionString").ConnectionString) Try connection.Open() Using command As OleDb.OleDbCommand = connection.CreateCommand command.CommandText = "SELECT * FROM examinationfee_TRANSACN" Dim table As New DataTable table.Load(command.ExecuteReader) gridincome.DataSource = table gridincome.DataBind() End Using Catch ex As Exception Response.Write(ex.Message) End Try End Using End Sub
P.S. i have the very same password set for the access file too!
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, May 7, 2016 3:50 PM -
User36583972 posted
Hi bhushan98,
Use Microsoft Jet OLE DB 4.0 to visit Access2003 data with database password as the below connection string.
Try to remove 'Persist Security Info=True'.
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:Database Password=MyDbPassword;
Some reports of problems with password longer than 14 characters. Also that some characters might cause trouble. If you are having problems, try change password to a short one with normal characters.
More detailed information about Access connection strings:
http://www.connectionstrings.com/access/
Best Regards,
Yohann Lu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 12, 2016 8:44 AM
All replies
-
User-18289217 posted
Please post the full exception message. Btw where do you set the connection string to the AccessDataSource? I couldn't see it.
Friday, May 6, 2016 9:50 PM -
User-2024981698 posted
sir
this is acess connection in web.config
<add name="incexpConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\modata\incexp.mdb;Persist Security Info=True;Jet OLEDB:Database Password=seeanu" providerName="System.Data.OleDb" /> </connectionStrings>
connection call in .vb
Dim sqldatasource2 As New SqlDataSource sqldatasource2.ID = "sqlincexp" SqlDataSource1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("incexpConnectionString").ConnectionString sqldatasource2.SelectCommand = " SELECT min_head_name, sum(amount) FROM(examinationfee_TRANSACN) WHERE tr_date between #" & stdate & " # and #" & enddate & " # GROUP BY min_head_name " Me.gridincome.DataSource = sqldatasource2 gridincome.DataBind()
Error :
Server Error in '/actweb' Application. Not a valid password. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: Not a valid password. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [OleDbException (0x80040e4d): Not a valid password.] System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +318 System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +88 System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +24 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) +38 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +507 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +154 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +21 System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +19 System.Data.OleDb.OleDbConnection.Open() +42 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +120 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +136 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +86
Pl. Help
I can't change database to sqlserver immediately
Saturday, May 7, 2016 12:56 PM -
User-18289217 posted
Hmm i have never seen this before. It's so confusing what you want to do. Please PM me the form and the database and i will fix that for you. That's the best that i can offer
P.S. why you set the conn string to the same object twice .. .is it a typo?
Dim sqldatasource2 As New SqlDataSource sqldatasource2.ID = "sqlincexp" SqlDataSource1.ConnectionString = etc. etc.
Saturday, May 7, 2016 1:07 PM -
User-18289217 posted
I've created an Access database containing a table with the same structure and i was able to load the foo data into the gridview with identical columns/fields
this is how do i bind the gridview ...
Private Sub Rebind() Using connection As New OleDb.OleDbConnection( ConfigurationManager.ConnectionStrings("incexpConnectionString").ConnectionString) Try connection.Open() Using command As OleDb.OleDbCommand = connection.CreateCommand command.CommandText = "SELECT * FROM examinationfee_TRANSACN" Dim table As New DataTable table.Load(command.ExecuteReader) gridincome.DataSource = table gridincome.DataBind() End Using Catch ex As Exception Response.Write(ex.Message) End Try End Using End Sub
P.S. i have the very same password set for the access file too!
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, May 7, 2016 3:50 PM -
User36583972 posted
Hi bhushan98,
Use Microsoft Jet OLE DB 4.0 to visit Access2003 data with database password as the below connection string.
Try to remove 'Persist Security Info=True'.
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:Database Password=MyDbPassword;
Some reports of problems with password longer than 14 characters. Also that some characters might cause trouble. If you are having problems, try change password to a short one with normal characters.
More detailed information about Access connection strings:
http://www.connectionstrings.com/access/
Best Regards,
Yohann Lu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 12, 2016 8:44 AM -
User-2024981698 posted
Thanks All. Now I am a step ahead. after using SqlDatasource /OLEDB . but now next error beings. if I use Kulrom Sir's Code
The error is :
System.ArgumentException was unhandled by user code
Message=Keyword not supported: 'provider'.
Source=System.Data
InnerException: ..........Then Connection String in web.config is :
<add name="incexpConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\modata\incexp.mdb;Persist Security Info=True;Jet OLEDB:Database Password=seeanu" providerName="System.Data.OleDb" />
The data binding code in .vb is
Using connection As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("incexpConnectionString").ConnectionString) Dim sqldatasource2 As New SqlDataSource() sqldatasource2.ID = "sqlincexp" sqldatasource2.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("incexpConnectionString").ConnectionString sqldatasource2.SelectCommand = " SELECT min_head_name, sum(amount) FROM(otherfee_TRANSACN) WHERE tr_date between #" & stdate & " # and #" & enddate & " # GROUP BY min_head_name " GRIDINCOME.DataSource = sqldatasource2 GRIDINCOME.DataBind() End Using
The Sqldatasource name on aspx page is : accessdatasouce
Pl. Help
Thanks
Saturday, May 21, 2016 3:29 AM -
User36583972 posted
Hi bhushan98,
I have made a sample on my side with two ways. The following methods for your reference.
1: OleDbConnection
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim Table_ As String = "Table1" Dim query As String = "SELECT * FROM " & Table_ 'Dim MDBConnString_ As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=TestDatabase.mdb;" Dim MDBConnString_ As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Database1.mdb;Jet OLEDB:Database Password=MyDbPassword;" Dim ds As New DataSet Dim cnn As OleDbConnection = New OleDbConnection(MDBConnString_) cnn.Open() Dim cmd As New OleDbCommand(query, cnn) Dim da As New OleDbDataAdapter(cmd) da.Fill(ds, Table_) cnn.Close() Dim t1 As DataTable = ds.Tables(Table_) Dim row As DataRow For Each row In t1.Rows Response.Write(row(0).ToString() + "_ " + row(1).ToString()) Next End Sub
2: SqlDataSource
Dim sqldatasource2 As New SqlDataSource() Dim MDBConnString_ As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Database1.mdb;Jet OLEDB:Database Password=MyDbPassword;" sqldatasource2.ID = "sqlincexp" sqldatasource2.ConnectionString = MDBConnString_ sqldatasource2.ProviderName = "System.Data.OleDb" sqldatasource2.SelectCommand = " SELECT * FROM Table1 " GridView2.DataSource = sqldatasource2 GridView2.DataBind()
Best Regards,
Yohann Lu
Tuesday, May 24, 2016 10:06 AM -
User-2024981698 posted
Thanks Sir,
I have copied ur data but I don't know why the result gird is not populated and visible at my place
My code at page_load is like :
Dim sqldatasource2 As New SqlDataSource()
Dim MDBConnString_ As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\Database1.mdb;Jet OLEDB:Database Password=MyDbPassword;"
sqldatasource2.ID = "sqlincexp"
sqldatasource2.ConnectionString = MDBConnString_
sqldatasource2.ProviderName = "System.Data.OleDb"
sqldatasource2.SelectCommand = " SELECT * FROM Table1 "
GridView1.DataSource = sqldatasource2
GridView1.DataBind()I have checked that the Gridview1.visible is True
Thanks
Thursday, May 26, 2016 6:22 PM -
User36583972 posted
Hi bhushan98,
You can refer the following options.
1: Your Database1.mdb file contains a Table named 'Table1'.
2: GridView is the default.
<asp:GridView ID="GridView2" runat="server"></asp:GridView>
GridView Control in ASP.Net :
http://www.c-sharpcorner.com/UploadFile/7eb164/gridview-control-in-Asp-Net/
3: In your debugger, serious to find problems. Others will give you related thoughts and ideas, but you need to combine your own program slightly modified.
If you have any questions, you can send new posts in related forums.
Best Regards,
Yohann Lu
Saturday, May 28, 2016 5:24 AM