Hi Miha,
No, unfortunately I am just learning C# and eventually I am going to need
to store and retrieve a lot of information. My database will be very, very
large.
Which is faster by the way. SQLServer or Access. I would imagine SQLServer
is faster.
I am shocked at the plethora of tools available and the many different
ways of doing things. I am overwhelmed to tell you the truth.
I found a little code that allows me to display a database in Access on
the screen. How do I write to the database for example. Furthermore, is
this example a good way to retrieve information or are there more
efficient methods. There seem to be so many ways, it's hard to know where
to start.
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=d:\\dbaccess\\db1.mdb");
//create the command object and store the sql query
// OleDbCommand aCommand = new OleDbCommand("select * from emp_test",
aConnection);
OleDbCommand aCommand = new OleDbCommand(
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.Write(aReader.GetInt32(0).ToString());
Console.Write(" {0} {1} ",aReader.GetString(1),aReader.GetString(2));
Console.WriteLine();
// Console.WriteLine(" {0} ",aReader.GetString(2));
}
Console.ReadLine();
//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);
}
}
}
TIA
Roy
Miha Markic said:
Hi Roy,
I guess you need a small database.
Perhaps you might look at MSDE 2000 or MSDE 2005 which are scaled down
versions of Sql Server 2000/2005 and are free (when distributed with a
application produced with MS tool I think - not sure about licensing).
--
Miha Markic [MVP C#]
RightHand .NET consulting & development
www.rthand.com
Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
Roy Gourgi said:
Hi,
I need to store and retrieve information from a database. It looks as
though there is a lot more support for SQLServer than there is for
Access, correct me if I am wrong.
What do I have to do to get SQLServer and which version should I be
using. Or is SQLServer already part of the VS.Net? Are there any good
examples that you know of.
TIA
Roy