Click here to Skip to main content
15,918,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: c#: Problems with accessing struct field members Pin
brexail23-Apr-08 0:09
brexail23-Apr-08 0:09 
GeneralRe: c#: Problems with accessing struct field members Pin
CPallini23-Apr-08 0:20
mveCPallini23-Apr-08 0:20 
GeneralRe: c#: Problems with accessing struct field members Pin
brexail23-Apr-08 0:30
brexail23-Apr-08 0:30 
GeneralRe: c#: Problems with accessing struct field members Pin
CPallini23-Apr-08 0:44
mveCPallini23-Apr-08 0:44 
GeneralRe: c#: Problems with accessing struct field members Pin
brexail23-Apr-08 2:47
brexail23-Apr-08 2:47 
QuestionPopulating Tree View.. Recursion?? Pin
Muammar©22-Apr-08 23:34
Muammar©22-Apr-08 23:34 
GeneralRe: Populating Tree View.. Recursion?? Pin
Muammar©22-Apr-08 23:46
Muammar©22-Apr-08 23:46 
GeneralOpen a database--Please disregard the question-i found the answer--Sorry for the trouble Pin
new2pgrmg22-Apr-08 23:31
new2pgrmg22-Apr-08 23:31 
Hi,

I am trying to open a MS Access database from C# code.

I want the MSAccess database to open up on a button click.

Am able to create a connection to the database but am unable to open the database.

i want the database to be open on a button click event so that i can open a table.

Atached below is my code.Any help is welcome Smile | :) .


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ADOX;
using System.Data.OleDb;
using System.Runtime.InteropServices;

namespace DatabaseCreation
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{


string strAccessConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtdatabaseName.Text;

OleDbConnection myAccessConn = null;

try
{

myAccessConn = new OleDbConnection(strAccessConn);

myAccessConn.Open();

MessageBox.Show("Database connection is successfully Opened");

}

catch (Exception ex)
{

MessageBox.Show("Error: Failed to create a database connection. \n{0}", ex.Message);

}

if (myAccessConn.State == ConnectionState.Open)
{

myAccessConn.Close();

MessageBox.Show("Database is successfully Closed");

}
}
}
}

modified on Wednesday, April 23, 2008 5:40 AM

GeneralRe: Open a database--Please disregard the question-i found the answer--Sorry for the trouble Pin
Thomas Stockwell23-Apr-08 8:20
professionalThomas Stockwell23-Apr-08 8:20 
Questionvalidate xml string against XSD Pin
anto200522-Apr-08 22:33
anto200522-Apr-08 22:33 
QuestionHow to Retun the multiple validation expression in single Regular Expression. Pin
bruze22-Apr-08 22:10
bruze22-Apr-08 22:10 
QuestionIs the .NET framework free? Pin
ptr2void22-Apr-08 21:22
ptr2void22-Apr-08 21:22 
AnswerRe: Is the .NET framework free? Pin
Ashfield22-Apr-08 21:44
Ashfield22-Apr-08 21:44 
GeneralRe: Is the .NET framework free? Pin
Christian Graus22-Apr-08 21:46
protectorChristian Graus22-Apr-08 21:46 
GeneralRe: Is the .NET framework free? Pin
ptr2void22-Apr-08 22:08
ptr2void22-Apr-08 22:08 
GeneralRe: Is the .NET framework free? Pin
Christian Graus22-Apr-08 22:10
protectorChristian Graus22-Apr-08 22:10 
GeneralRe: Is the .NET framework free? Pin
ptr2void22-Apr-08 22:20
ptr2void22-Apr-08 22:20 
GeneralRe: Is the .NET framework free? Pin
CPallini22-Apr-08 22:30
mveCPallini22-Apr-08 22:30 
GeneralRe: Is the .NET framework free? Pin
Reelix23-Apr-08 1:27
Reelix23-Apr-08 1:27 
GeneralRe: Is the .NET framework free? Pin
CPallini23-Apr-08 1:43
mveCPallini23-Apr-08 1:43 
GeneralRe: Is the .NET framework free? Pin
Reelix23-Apr-08 1:56
Reelix23-Apr-08 1:56 
QuestionRe: Is the .NET framework free? Pin
CPallini23-Apr-08 1:58
mveCPallini23-Apr-08 1:58 
GeneralRe: Is the .NET framework free? Pin
Zoltan Balazs22-Apr-08 22:31
Zoltan Balazs22-Apr-08 22:31 
GeneralRe: Is the .NET framework free? Pin
Reelix22-Apr-08 22:13
Reelix22-Apr-08 22:13 
GeneralWaitOne exitContext Pin
George_George22-Apr-08 20:55
George_George22-Apr-08 20:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.