I'm looking for examples, tutorials, or just "this+this+this should work" for reading from and writing to a SQL server (2008) from a microcontroller such as the Arduino board. I've also looked at (and will probably go with) devices with the .Net Micro Framework such as the Fez Cobra. The Micro Framework does not include ADO. I'm sure this is going to involve some XML, but I can't figure out which technology to further investigate. I do not want to have an PC application to serve as a go-between.
Thanks!
To connect to the Database Engine from another computer On a second computer that contains the SQL Server client tools, log in with an account authorized to connect to SQL Server, and open Management Studio. In the Connect to Server dialog box, confirm Database Engine in the Server type box.
The most commonly used network protocol in SQL Server is the TCP/IP protocol. This protocol connects computers with different hardware and operating systems specs and allows it to communicate together, as it includes network traffic routing standards with advanced security protection.
Honestly, I would make a thin service that would sit in-front of your database and use something lightweight like protobuf to get the data into your micro.
I doubt you'll be able to implement TDS in the limited power and memory of an AVR.
Still not sure what your question is about... The tag "arduino" let me think you are asking about Arduino code, but the comment below make me doubt you are asking for .NET stuff. Here's a tentative answer should the question be on how to manage things on the Arduino side.
On the Arduino, I would simply output SQL queries on the Serial port, like this:
Serial.begin(115200);
Serial.println("INSERT INTO table_name VALUES (value1, value2, value3,...);");
On the server side (or on the side of the computer you are using to access the Internet), I would write a simple script that opens the connection with the DB and forward the query to it. This could be achieved either by CLI commands or opening a network connection on a given port. I do not use Windows/.NET, etc... but on a GNU/Linux box, using python and mysql, the proof-of-concept code that I would write would look something like (BEWARE: UNTESTED!):
import os, serial
self.ser = serial.Serial("/dev/ttyUSB0", 115200)
query = self.ser.readline().strip()
return os.popen("mysql -u<my_usr> -hlocalhost -p<my_pass> -e" + query)
The latter will be shipped sometimes soon (see this presentation if you are curious about it). The first is already available. Writing the code for it should be dead easy (see docs here). The result should be something down the line of (UNTESTED):
Serial.begin(<speed>);
Ethernet.begin(<mac_number>, <ip>);
Client client(<server>, <port>);
client.println("GET <path> HTTP/1.0");
while (client.available()) {
char c = client.read();
Serial.print(c);
}
HTH!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With