 |
|
 |
Thank you! This info is what I've been searching for!
|
|
|
|
 |
|
 |
I'm developing an application to Windows Mobile 5, using Visual Studio 2005, and my ideia is to connect from that application to a remote MySQL database.
This article shows how to do it for .NET applications.
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1288&lngWId=10
My question is, it can be done for Windows Mobile as well? Because it don't seems to support OLE DB reference.
Thanks in advance,
Carlos
|
|
|
|
 |
|
 |
Hi Nish,
Can this method / class be used on a SQL-CE device (using MFC / C++ unmanaged code)
Cheers
Alex
|
|
|
|
 |
|
 |
AlexEvans wrote: Can this method / class be used on a SQL-CE device (using MFC / C++ unmanaged code)
I am not sure of that Alex. Depends on if the device supports OLE DB.
|
|
|
|
 |
|
 |
Hello again,
Just noticed in the article - this is using MANAGED code, Mobile devices do not support this unfortunately...
OLE DB is the only method supported, no ODBC, no ADO
Cheers
Alex
|
|
|
|
 |
|
 |
Nish,
This is the most helpful example I've come accross for starting up in DB programming. I appreciate the fact that you stick to the basics here.
I have a question. What would be a good way to edit one of the records that you created?
Thanks,
Kain
|
|
|
|
 |
|
 |
kstrat2001 wrote: This is the most helpful example I've come accross for starting up in DB programming. I appreciate the fact that you stick to the basics here.
Thanks Kain - wrote this a long time ago though
kstrat2001 wrote: What would be a good way to edit one of the records that you created?
You could pass an UPDATE query to the OleDbCommand object.
Or you could use a DataGrid (or the newer .NET 2.0 GridView) - which helps in more complex scenarios.
|
|
|
|
 |
|
 |
Hi Nish,
please clear my doubts:
How to have access to the *.mdb file, if it exists on some other machine on LAN?
Can we have connection pooling, since there would be many users accessing the *.mdb file?
with thank and regards
ritesh kumar verma
|
|
|
|
 |
|
 |
Why this error occurs
Unhandled Exception: System.SystemException: The .Net Data OLE DB Provider(S
m.Data.OleDb) requires Microsoft Data Access Components(MDAC) version 2.6 or
er. Version 02.10.3711.9 was found currently installed.
at System.Data.OleDb.OleDbConnection.CreateInstanceMDAC()
at System.Data.OleDb.OleDbConnection.GetObjectPool(Boolean parsing)
|
|
|
|
 |
|
|
 |
|
 |
how do i pass the arguments to s i tryed this maybe you could help me out i cant get it to accept input to the array to add to the DB im new to programming so maybe you could help me out?
using System.Data.OleDb;
using System;
class nish
{
public static void Main(string[] s)
{
Console.WriteLine("Enter the name please");
s[0] = Console.ReadLine();
Console.WriteLine("Enter the Age now please");
s[1] = Console.ReadLine();
//check and see if they have entered the two arguments
//if they have then proceed
if(s.Length==2)
{
//create the OleDb connection object
OleDbConnection conn=new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb");
//Open the OleDb connection
conn.Open();
//Declare a command object so we can issue SQL commands to the connection
OleDbCommand cmd;
//Create the SQL using the command line arguments
string sql="insert into table1 values('" + s[0] + "','" +s[1]+"')";
//construct the command object passing the SQL and the connection object as parameters
cmd=new OleDbCommand(sql,conn);
//Now execute the SQL
cmd.ExecuteNonQuery();
//Close the connection
conn.Close();
}
else //if they have entered less than 2 arguments or more than 2 arguments
//show the following error messageam
{
Console.WriteLine("Wrong number of arguments!");
Console.WriteLine("Use :- dbinsert [name] [age]");
}
}
}
|
|
|
|
 |
|
 |
You are not doing it right.
static void Main(string[] s)
Here s is NOT a string array that you can use. s is the list of command line arguments passed to the program. If you want to use your own string array, you have to declare it.
Hope this helps
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
 |
|
 |
I can't help asking the folowing questions:
1. Is this code supposed to explain something good about .NET or C#? It seems you can do the thing demonstrated here easily with other technology (MFC for example).
2. Does the same code work without heavy modification for other non-microsoft databases, such as Oracle, Sybase, etc. ?
|
|
|
|
 |
|
 |
a reader wrote:
Is this code supposed to explain something good about .NET or C#? It seems you can do the thing demonstrated here easily with other technology (MFC for example).
It's just an introduction for people who want to do OLE DB programming with .NET. It's not something special about .NET.
a reader wrote:
Does the same code work without heavy modification for other non-microsoft databases, such as Oracle, Sybase, etc. ?
Yes. But you'll need to change the connection string accordingly
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
 |
|
 |
I have updated the article for beta 2.0
When I wrote the article I was on beta 1
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
 |
|
 |
I try to compile the sample code and got this.
Is ADO still a valide namespace in .Net SDK Beta 2?
thanks
The type or namespace name 'ADO' does not exist in the class or namespace 'System.Data' (are you missing an assembly reference?)
|
|
|
|
 |
|
 |
Hi
I have updated the article for beta 2.0
I should have done that already, but I kept postponing it.
sorry for the lethargy
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
 |
|
 |
Good morning,
You are problably wakeup, now we are using version Beta 2. Your samples will not work in the current version. There are significant changes!
Please, update your development environment, evaluate .Net and bring something more than we can read from the MSDN docs.
Thanks.
P.S.
Your program missing an exception handling included cleanup connection.
|
|
|
|
 |
|
 |
The article has been updated.
I wish you'd log in.
If you had done that, then I'd have got a notification
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
 |
|
 |
buster
Good work again.You could write something like this showing how to select records from a database. Maybe a part-2.
Thanks
Jingo
|
|
|
|
 |
|
 |
Thank you.
yeah, that's an idea...
Nish
|
|
|
|
 |
|
|
 |
|
 |
Perhaps instead of providing a warning that the program will crash with an exception maybe you could add a simple exception handler to the application. Just a thought.
|
|
|
|
 |
|
 |
sorry
my mistake...
I guess I should have done that...
actually I kinda thought of it then thought exception handling would require further explanations...
anyway for those of you who wanta try it out
put the code you wanta try in a try block and catch it in a catch block as shown below:-
try
{
//code goes here
}
catch(System.Exception e1)
{
//do your handling here
}
regards and thanks
Nish
|
|
|
|
 |