الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

قواعد بيانات access

بدأه alz3im في 20 فبراير 2011 · 6 رد · 619 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

ممكن المساعد فى كيفة ربط قواعد بيانات access 2003 وزايد الكود

ولكم جزيل الشكر والتقدير
#2

جرب الكونكشن التالي :

//create the database connection
OleDbConnection MyConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\MyDB.mdb");

قل لمن يحمل هما ****** إن همــــا لا يدوم
:rolleyes: :rolleyes: :clapping: :rolleyes: :rolleyes:

مثلا تفنى المسـرة ***** هكذا تفنى الهموم

#3

طريقة الكونيكش لو سمحت

#4

هذا مثال كامل :

using System;
using System.Data.OleDb;

class OleDbTest{

public static void Main()
{
//create the database connection
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb");

//create the command object and store the sql query
OleDbCommand aCommand = new OleDbCommand("select * from emp_test", aConnection);
try
{
aConnection.Open();

//create the datareader object to connect to table
OleDbDataReader aReader = aCommand.ExecuteReader();
Console.WriteLine("This is the returned data from emp_test table");

//Iterate throuth the database
while(aReader.Read())
{
Console.WriteLine(aReader.GetInt32(0).ToString());
}

//close the reader 
aReader.Close();

//close the connection Its important.
aConnection.Close();
}

//Some usual exception handling
catch(OleDbException e)
{
Console.WriteLine("Error: {0}", e.Errors[0].Message);
}
}
}

قل لمن يحمل هما ****** إن همــــا لا يدوم
:rolleyes: :rolleyes: :clapping: :rolleyes: :rolleyes:

مثلا تفنى المسـرة ***** هكذا تفنى الهموم

#5

جزاك الله خير شباب

انا عندى كود لكن بيعطين خط لو امكن حد يصحح لى الخطا

وجزاكم الله خير

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsFormsApplication1;

namespace testaccess
{
    public partial class Form7 : Form
    {
        testaccess.db1 CDB1Opj;

        public Form7()
        {
            InitializeComponent();
            CDB1Opj = new testaccess.db1();
        }

        private void Form7_Load(object sender, EventArgs e)
        {
            DGVinfo.DataSource = testaccess.db1.GetAllInfo("city");
        }

        private void DGVinfo_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
#6

السلام عليكم و رحمة الله و بركاته

اخي الفاضل

هل testaccess.db1 هو الDataset الذي يحمل صورة من قاعدة البيانات؟

و اذا كانت GetAllInfo يرجع DataTable يفضل تعديل هذا السطر الي

DGVinfo.DataSource = testaccess.db1.GetAllInfo("city").DefaultView;

تقبل خالص تحياتي

#7

مشكووورين شباب على الردود ويديكم العافيــــه

مواضيع مشابهة