oleDbConnection1->Open();
DataSet *dataSet11=new DataSet;
OleDbDataAdapter *oleDbDataAdapter1= new OleDbDataAdapter("select * from project where code=@textBox1->Text",oleDbConnection1);
oleDbDataAdapter1->Fill(dataSet11,"project");
dataGrid1->DataSource=dataSet11;
dataGrid1->DataMember="project";
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Connect_access
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String connect = "Provider=Microsoft.JET.OLEDB.4.0;data source=.\\ClassProjects.mdb";
OleDbConnection con = new OleDbConnection(connect);
con.Open();
MessageBox.Show("Made the connection to the ClassProjects database");
con.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Connect_access
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
String connect = "Provider=Microsoft.JET.OLEDB.4.0;data source=.\\ClassProjects.mdb";
OleDbConnection con = new OleDbConnection(connect);
OleDbCommand myOleDbCommand = con.CreateCommand();
myOleDbCommand.CommandText =
"SELECT * " +
"FROM PROJECT " +
"WHERE Code = 'INT202'";
con.Open();
OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
myOleDbDataReader.Read();
MessageBox.Show("myOleDbDataReader[\" Code\"] = " + myOleDbDataReader["Code"]);
MessageBox.Show("myOleDbDataReader[\" Number\"] = " + myOleDbDataReader["Number"]);
MessageBox.Show("myOleDbDataReader[\" Title\"] = " + myOleDbDataReader["Title"]);
MessageBox.Show("myOleDbDataReader[\" Due\"] = " + myOleDbDataReader["Due"]);
MessageBox.Show("myOleDbDataReader[\" Points\"] = " + myOleDbDataReader["Points"]);
con.Close();
}
}
}
myOleDbCommand.CommandText =
"SELECT * " +
"FROM PROJECT " +
"WHERE Code = '" + textBox1.Text + "'";
دیتابیس مذکور را هم از اینجا با حجم حدود 300 کیلو دانلود کنید.
http://www.hammerdata.com/Google/ClassProjects.mdb
DataSet *dataSet11=new DataSet;
str="SELECT * FROM project WHERE code=S'"+ textBox1->Text + "'";
OleDbDataAdapter *oleDbDataAdapter1= new OleDbDataAdapter(str,oleDbConnection1);
oleDbDataAdapter1->Fill(dataSet11,S"project");
لینکش در تاپیک یادگیری سی شارپ هست.Visual C#® 2005: How to Program, Second Edition
By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.
Publisher : Prentice Hall
Pub Date : December 15, 2005
Print ISBN-10 : 0-13-152523-9
Print ISBN-13 : 978-0-13-152523-8
eText ISBN-10 : 0-13-133214-7
eText ISBN-13 : 978-0-13-133214-0
Pages : 1648
Visual C# 2005 How to Program (2nd Edition
چون سایت وارز بود عکس لینک را گذاشتم. خودتان تایپ کنید.
باید اینجا ثبت نام کنید تا بتوانید مجانی دانلود کنید.
حجم : در حدود 28 مگا.
Free computer books
Best free J2EE books
Best free .NET books
Best free XML books
Best free PHP books
Free Java books
Free J2EE books
Free JSP books
Free J2ME books
Free .NET books
Free C# books
Free ASP.NET books
Free VB.NET books
Free VS.NET books
Free Oracle books
Free Linux books
Free MySql books
More free books
Free MSDN Mags
Free Oracle Mags
Free software CDs
تک بک اسلش می شود escape و دو بک اسلش می شود مساوی یک بک اسلش.
■CHAPTER 12 ADO.NET and Database Development
dAdapt->SelectCommand =
gcnew SqlCommand("SELECT AuthorID, LastName, FirstName"
"FROM Authors", connect);
gcnew SqlCommand("INSERT INTO Authors (LastName, FirstName) "
"VALUES (@LastName, @FirstName)", connect);
gcnew SqlCommand("UPDATE Authors SET "
"LastName = @LastName, FirstName = @FirstName, "
"WHERE AuthorID = @AuthorID", connect);
dAdapt->UpdateCommand->Parameters->Add("@FirstName", SqlDbType::VarChar, 50,
"FirstName");
dAdapt->UpdateCommand->Parameters->Add("@AuthorID", SqlDbType::Int, 4,
"AuthorID");
gcnew SqlCommand("UPDATE Authors SET "
"LastName = @LastName, FirstName = @FirstName, "
"AuthorID = @AuthorID "
"WHERE AuthorID = @OldAuthorID", connect);
dAdapt->DeleteCommand =
gcnew SqlCommand("DELETE FROM Authors "
"WHERE AuthorID = @AuthorID", connect);
dAdapt->DeleteCommand->Parameters->Add("@AuthorID", SqlDbType::Int, 4,
"AuthorID");
String ^constr ="Provider=Microsoft.JET.OLEDB.4.0;data source=.\\ClassProjects.mdb";
OleDbConnection ^con = gcnew OleDbConnection(constr);
OleDbCommand ^myOleDbCommand = con->CreateCommand();
myOleDbCommand->CommandText =
"SELECT * " +
"FROM PROJECT "+
"WHERE Code = '" + textBox1->Text + "'";
con->Open();
OleDbDataReader ^myOleDbDataReader = myOleDbCommand->ExecuteReader();
myOleDbDataReader->Read();
MessageBox::Show("myOleDbDataReader[\" Code\"] = " + myOleDbDataReader["Code"]);
MessageBox::Show("myOleDbDataReader[\" Number\"] = " + myOleDbDataReader["Number"]);
MessageBox::Show("myOleDbDataReader[\" Title\"] = " + myOleDbDataReader["Title"]);
MessageBox::Show("myOleDbDataReader[\" Due\"] = " + myOleDbDataReader["Due"]);
MessageBox::Show("myOleDbDataReader[\" Points\"] = " + myOleDbDataReader["Points"]);
con->Close();
DataSet* Employee::Lookup(String* name)
{
DataSet* ds = new DataSet("Employees");
StringBuilder* query = new StringBuilder();
query->Append("SELECT * FROM Employees WHERE EmployeeName Like '%");
query->Append(name);
query->Append("%'");
OleDbDataAdapter* adapter = new OleDbDataAdapter(query->ToString(),
ConnStr);
try
{
adapter->Fill(ds," Employees");
}
catch (OleDbException* e)
{
Console::WriteLine("OleDbException caught while filling the dataset");
Console::WriteLine(e->Message);
}
return ds;
}