Click here to Skip to main content
15,888,527 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# and Windows'98 Pin
Rickard Andersson205-Dec-02 0:49
Rickard Andersson205-Dec-02 0:49 
GeneralRe: C# and Windows'98 Pin
djkno35-Dec-02 1:31
djkno35-Dec-02 1:31 
GeneralRe: C# and Windows'98 Pin
Rickard Andersson205-Dec-02 1:57
Rickard Andersson205-Dec-02 1:57 
GeneralRe: C# and Windows'98 Pin
djkno35-Dec-02 12:05
djkno35-Dec-02 12:05 
GeneralRe: C# and Windows'98 Pin
Rickard Andersson205-Dec-02 20:42
Rickard Andersson205-Dec-02 20:42 
GeneralRe: C# and Windows'98 Pin
Christian Graus5-Dec-02 6:33
protectorChristian Graus5-Dec-02 6:33 
Generalsimple connection to Access database in c# Pin
Abu Atwan4-Dec-02 13:36
Abu Atwan4-Dec-02 13:36 
GeneralRe: simple connection to Access database in c# Pin
Nick Parker4-Dec-02 17:55
protectorNick Parker4-Dec-02 17:55 
Abu Atwan wrote:
Anyone tell me about creating simple connection to Access database in c# using datagrid, and textboxes.

Sure here is a quick example:
string sql;
sql = GetSearchString();<font color=green>  //function that creates my SQL statement</font>
try
{
	string myConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" 
         +  "Data Source=" + @"C:\Documents and Settings\User\Desktop\phonebook\phonebook.mdb";
	OleDbConnection myConnection = new OleDbConnection(myConnString);
	myConnection.Open();
	OleDbCommand myCommand = new OleDbCommand();
	myCommand.Connection = myConnection;
	myCommand.CommandText = sql;
	OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myCommand);
	DataSet myDataSet = new DataSet();
	myDataAdapter.Fill(myDataSet);
	this.dataGrid1.DataSource = myDataSet;
	this.dataGrid1.Visible = true;
	myConnection.Close();
}
catch(Exception err)
{
	MessageBox.Show("An error has occured\n\n" + err.Message + "\n" + err.Source + "\n", "Phone Book Error");
}


Hope this helps. Smile | :)



Nick Parker

Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein


GeneralC# Office Addins Pin
Chris Ormerod4-Dec-02 13:27
Chris Ormerod4-Dec-02 13:27 
GeneralRe: C# Office Addins Pin
Kannan Kalyanaraman4-Dec-02 19:03
Kannan Kalyanaraman4-Dec-02 19:03 
Generaltray icon Pin
grv5754-Dec-02 12:49
grv5754-Dec-02 12:49 
GeneralRe: tray icon Pin
David Stone4-Dec-02 12:56
sitebuilderDavid Stone4-Dec-02 12:56 
GeneralRe: tray icon Pin
grv5754-Dec-02 21:00
grv5754-Dec-02 21:00 
GeneralRe: tray icon Pin
Kannan Kalyanaraman4-Dec-02 19:07
Kannan Kalyanaraman4-Dec-02 19:07 
GeneralTreeNode selection Helppppp Pin
Nicholas Naddaf4-Dec-02 8:37
Nicholas Naddaf4-Dec-02 8:37 
GeneralRe: TreeNode selection Helppppp Pin
Chris Austin4-Dec-02 8:46
Chris Austin4-Dec-02 8:46 
GeneralRe: TreeNode selection Helppppp Pin
Nicholas Naddaf4-Dec-02 8:50
Nicholas Naddaf4-Dec-02 8:50 
GeneralRe: TreeNode selection Helppppp Pin
Nicholas Naddaf4-Dec-02 9:27
Nicholas Naddaf4-Dec-02 9:27 
GeneralListbox header column bitmaps Pin
MariaWard4-Dec-02 8:36
MariaWard4-Dec-02 8:36 
GeneralRe: Listbox header column bitmaps Pin
Nick Parker4-Dec-02 9:03
protectorNick Parker4-Dec-02 9:03 
GeneralThat AppUpdater thing from GotDotNet Pin
Tom Welch4-Dec-02 6:39
Tom Welch4-Dec-02 6:39 
GeneralRe: That AppUpdater thing from GotDotNet Pin
Nathan Tran4-Dec-02 6:46
Nathan Tran4-Dec-02 6:46 
GeneralClientside UserControl Pin
Peter Kiss4-Dec-02 2:45
Peter Kiss4-Dec-02 2:45 
GeneralRe: Clientside UserControl Pin
John Rayner4-Dec-02 7:34
John Rayner4-Dec-02 7:34 
GeneralRe: Clientside UserControl - without success Pin
Peter Kiss6-Dec-02 5:09
Peter Kiss6-Dec-02 5:09 

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.