Problem Regarding MS Access database connection in c#.net

hi friend ..

i m new in this field.

i m creating some basic database application in asp.net mobile for web application.

but i m facing problem to set the database path dynamically .Means i dont want write whole path of my datbase file in data source.Suppose i change my path then i m changing whole path every time this is very hectic problem.

So plz anyone suggest me how to set my database file dynamically .

I m attached my connection of database code.

Thanks And Regards.

Pash Inda 

 

protected void Page_Load(object sender, EventArgs e)

{ //All controls on this page visible to user

Label1.Visible = true;

Label2.Visible = true;

Label3.Visible = true;

labelerror1.Visible = true;

labelerror2.Visible = true;

TextBox1.Visible = true;

TextBox2.Visible = true;

Command1.Visible = true;

Command2.Visible = true;

} string query;

string databasepath = @"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=F:\prashant\Dotnet\MobileProject\PhoneBook\App_Data\Contact_Info.mdb";

OleDbConnection connection = null; //****************************SearchCommand For Name ******************************************************// protected void Command1_Click(object sender, EventArgs e) { string username = Session["user"].ToString(); if (TextBox1.Text.ToString() == "") { labelerror1.Text = "Plz Enter Name"; } else { query = "SELECT Name,PhoneNo,EmailID from contact_info where Name='" + TextBox1.Text.ToString()+"' AND username='"+username+"'"; //searchrecord function showSearchrecord(query); } }

0
prashant11
5/21/2008 9:47:56 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

1 Replies
987 Views

Similar Articles

[PageSpeed] 6

You can use the OleDbConnectionStringBuilder class:

        OleDbConnectionStringBuilder ConObj = new OleDbConnectionStringBuilder();

        ConObj.Provider = "Microsoft.Jet.OLEDB.4.0";
        ConObj.DataSource = @"F:\prashant\Dotnet\MobileProject\PhoneBook\App_Data\Contact_Info.mdb"; 

        String ConnString = ConObj.ConnectionString;
 
Steve Wellens

My blog
0
SGWellens
5/21/2008 11:43:36 AM
Reply:

Similar Artilces:

problems with connections to access via ADO.NET in VS.NET
For anyone familiar with this book, I am having trouble with some code in Chris Payne's "SAMS Teach Yourself ASP.NET in 21 Days", which calls for me to use ADO.NET to connect to an Access database I had to create for the "In Review" project after the second week. The code goes like this (within the first subroutine): dim Conn as new OleDbConnection("Provider= Microsoft.Jet.4.0; Data Source=C:\Inetpub\wwwroot\TYASPNET\banking.mdb") Now I've tried this, along with setting up a connection through the server explorer in Visual Studio.NET. When I go to run the page, I...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

database connection problem using C# .net 2.0
 Hi,I am learning C# .net 2.0. I use below code to connect database. But, it gave me an error message as below. Please help me. string strConn = WebConfigurationManager.ConnectionStrings["SqlConnectionstring"].ConnectionString;  SqlConnection objConnect = new SqlConnection(strConn);-----------------------------------------------------Server Error in '/DOTNET2005' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Problem with Connection of Informix .NET Provider with .NET.
Hello All, I am facing problem regarding connection of .NET with IBM Informix .NET Data Provider.I got a help from IBM site of Manual to connect with .NET and accessing informix as a informix .net data provider you need to import IBM.Informix.data as a namespace to access .NET based informix classes as similar to access sql server using namespace system.data.sqlclient.In that manual written as following---- Before you use the IBM Informix .NET Provider, you must execute the script, cdotnet.sql, against the sysmaster database as the user informix. So, my problem is that...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

Access Database Connection/Query Problem: "Object reference not set to an instance of an object"
I have been working on a web site in Visual Web Developer for several months.  For no apparent reason, I can no longer create, modify, or connect to my Microsoft Access database source.  The database is still where it has always been, still opens, etc.  Below are a few of the symptoms.  Does anyone know what would cause this and more importantly how I can fix it? (1) I can no longer use the "Query Builder" with existing or new aspx pages; when I try I get this message: "Object reference not set to an instance of an object" (2) I tried using the "Design Custom Statement...

Connect to MS Access with ADO.Net
I connect PB 10.5 to MSAccess with ADO.Net with the following connection string; // Profile SQLCA.DBMS = "ADO.Net" SQLCA.AutoCommit = False SQLCA.DBParm = "Namespace='System.Data.OleDb',DataSource='c:\datos.mdb',Provider='Microsoft.Jet.OLEDB.4.0' ,TrimSpaces=1,OJSyntax='ANSI',DelimitIdentifier='No',DateFormat='#dd-mm-yyyy#' ,DateTimeFormat='#dd-mm-yy hh:mm:ss#',TimeFormat='#hh:mm:ss#'" but PB not recognize the primary keys of the tables ?? In the IDE i can't change data and save changes ??? ...

problem connecting .net with access in 64bit
Hi, I have created a quite big web application in a windows 32-bit system with c# that uses an access database with the jet engine (4). Lately, we have to move the whole thing to a new 64bit server - with windows 2003 64-bit. The aspx pages work fine, but wherever I try to open the mdb it fails with a message that ole.jet engine is not registered on this machine. I searched a bit and I reinstalled mdac 8, but no luck at all. I also tried to install some service packs for jet engine (64bit) but it always says that it is not for this hardware. When I try to check the odbc drivers it also...

Innovation to ADO.NET
Matisse Software Inc. provides its native ADO.NET Data provider for Matisse 6.0, the Database for .NET. Matisse Software has pushed the envelope of Microsoft ADO.NET architecture and extended it into a powerful Object Access Services component for .NET. Matisse’s extension of ADO.NET demonstrates that ADO.NET can evolve beyond the Microsoft architecture to benefit .NET developers. Unlike the standard ADO.NET data provider, which returns data in a table format to integrate seamlessly with relational products, Matisse has extended the ADO.NET architecture to return data in an object format....

accessing MS Access from .net
hi I am accessing ms access data base which has a table called customers. when i try to insert data into the table i am gettign the error like "Operation must use an updatable query" and the line its showing is myOleDbcommand.ExecuteNonQuery() here is my code in page lode event Sub Page_Load(Sender As Object, E As EventArgs) Dim StrConnectString as String Dim strStatement as String strConnectSTring = "Provider=Microsoft.Jet.OLEDB.4.0;Password='';User ID=Admin;Data Source=C:\Inetpub\wwwroot\Srinu\WebApplication2\...

How to access Mozilla Objects from .NET C#
Hi All,I have been dying to develop an automation suite for Mozilla browser. The suite should be able to open the browser, navigate to the URL and perform actions like click and etc. I guess it could be achieved by mozctl.dll which comes with the mozilla activex control v1.7.12. The MozillaBrowser class inside the mozctl.dll has the necessary functions like navigate and document etc which can be used to get the control over the elements inside the DOM. The major issue I am facing is, when I write the code\ MozillaBrowser m = new MozillaBrowser(); m.Navigate(“Yahoo.com”, ref o, ref ...

vb.net vs c#.net vs j#.net
just out of curiousity which looks, acts most like java? i'm still learning trying to used to vb.net but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

Web resources about - Problem Regarding MS Access database connection in c#.net - asp.net.object-datasource

Connection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

iMedia Connection: Interactive Marketing News, Features, Podcasts and Video - iMediaConnection.com
High-quality data, if not used properly, can still lead marketers to make bad decisions. Consider these common ways that numbers are used to ...

HTTP persistent connection - Wikipedia, the free encyclopedia
... tacked on to an existing protocol. If the browser supports keep-alive, it adds an additional header to the request: Following this, the connection ...

CareerSonar Turns Facebook Friends Into Job Connections
Looking for a job ? Among your Facebook friends lies the potential for employment. CareerSonar , a new service, brings together a person’s connections ...

Ben Garcia gives Penrith Panthers a new French connection
Should he jag a game in the NRL, Ben Garcia will become just the third genuine French import to do so.

Man Charged With Aggravated Arson In Connection To Columbus Warehouse Fire
Police have charged 30-year-old Robin Toms with aggravated arson.

Facebook becomes more adept at dealing with crappy connections
... to get a decent phone signal to allow you to post a photo of your meal. Joking aside, in countries where people are struggling with 2G connections ...

Adam Savage from 'MythBusters' has an incredible connection to the 'Star Wars' franchise
Adam Savage, co-host of the popular " MythBusters " television show, soured on the plot of "Interstellar." But when it comes to the newest films ...

French authorities detain suspects in connection to attacks 10 months apart
CNN French authorities detain suspects in connection to attacks 10 months apart CNN A forensic scientist works near a Paris cafe on Saturday, ...

UK Police Make Arrest in Connection With VTech Hacking
British law enforcement officials arrest a 21-year-old man in connection with attack on toy maker VTech that exposed 6 million parents and children ...

Resources last updated: 12/22/2015 2:59:00 PM