Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Connecting to SQL Server using SIM300

Status
Not open for further replies.

Shivashankarayya

Junior Member level 2
Joined
Apr 10, 2010
Messages
22
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,283
Location
Bangalore, INDIA
Activity points
1,439
Hi everyone,

Hope U all r fine:D

I am using SIM300 module for my project, i want to connect to SQL Server by using SIM300 module and upload the data to SQL Server data base. Is possible ...? if yes then please suggest me how to do....

Waiting for your valuable suggestions...
 

See the FAQ here **broken link removed** for details on opening a TCP/IP connection and sending data to a server. If you need info on how to write server code to receive and store the data look at: www.W3Schools.com.
 

I gone through the links which u had mentioned. But the thing is, I want to upload the data to SQL server (Microsoft SQL server 2005) i.e manually i created a table in Microsoft SQL server 2005->SQL Server management studio, then from SIM300 module i did the TCP/IP connection to the SQL server ip address and its port number(default 1433), Once the connection is established, what ever data i transfer from client(SIM300) to server should update in that created table ... is it possible..? If yes then please let me know.
Using the SQL Server native HTTP support is a fairly complicated procedure that's beyond the scope of a simple post. If you want to go that route you should research the web. A good place to start is:https://www.exforsys.com/tutorials/sql-server-2005/native-http-support-in-sql-server-2005.html.

A more common approach is to include your data in the HTTP request (GET or POST), parse that data on the server and store it in database. Below is a sample ASP page that does this. Using this approach you can test your code using a web browser.
Code:
<%@ LANGUAGE=VBSCRIPT %>
<% Option Explicit%>

<%
' This ASP page receives a HTTP request that contains data from a GSM-based device and stores it in a database (this code uses an Access database).  
' In this example, the data is a set of measured voltage and current values with an associated time-stamp.
' The request includes the following:
'  IMEI - the IMEI number of the radio sending the request
'  Number - The phone number of the radio sending the request
'  Data -  This is a set of comma-delimited data that contains the Date & time, voltage and current. Each field is seperated by a comma. Multiple packets can be 
'          sent, with a semi-colon between packets. To conserve space and increase throughput, the Date & time are sent as a "Unix Epoch Time" value.
'
' Example request with 3 data points:
' 	 IMEI=123456&Number=2125551212&data=1244994322,1.23,3.4;1244994323,1.25,3.4;1244994324,1.24,3.3;

' The database contains the following fields, of the specified types:
'  ID - AutoNumber
'  IMEI - Text
'  Date - Long Integer
'  Voltage - Single
'  Current - Single

	If Err.Number <> 0 then			' If we get an error display it - aids debugging
	   Response.Write(Err.Description)
	   Error.Clear
	End If
	  
	' The METHOD constant determines which method (POST or GET) is being used to send the data- comment-out one of them
	' Normally a POST should be used, but by setting this to 'GET' you can easily test the code using a Browser by placing the request in the URL. i.e. 
	'   [url]www.MyServer.com/Savepowerdata.asp?IMEI=123456&Number=2125551212&data=1244994322,1.23,3.4;1244994323,1.25,3.4;1244994324,1.24,3.3;[/url]	  
	Const METHOD = "POST"
'	Const METHOD = "GET"

	Const MY_DATA_BASE = "Data\PowerData.mdb"   ' Path & filename of our database
	Const TABLE_NAME = "PowerData"				' Name of the table we store the data in
	Dim db_connection_string
	Dim rsData
	Dim data_string, remote_addr
	Dim imei, phone_number, time, voltage, current
	Dim end_field, start_field
    
	' Extract the IMEI, Phone Number and Data string from the request
if METHOD = "POST" then
   ' These three lines are used if a POST request is being accepted (this is the recommended method)	
   data_string = Request.form("Data")
   imei = Request.form("Imei")
   phone_number = Request.form("Number")
else
	' These three lines should be used if a GET request is being accepted
   data_string = Request.QueryString("Data")
   imei = Request.QueryString("Imei")
   phone_number = Request.QueryString("Number")
end if

	' Open the recordset that contains our data
	db_connection_string = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath(MY_DATA_BASE) & ";"
	Set rsData = Server.CreateObject("ADODB.Recordset")
	rsData.Open "SELECT * FROM " & TABLE_NAME, db_connection_string, adOpenStatic, adLockPessimistic, adCmdText
	start_field =1
	' Parse each data-point from the data string and save it in the database
	do
		   end_field = instr(start_field, data_string, ",")	 					   ' Find comma after Date/Time number
		   if end_field > 0 then 
		   	  time = mid(data_string, start_field, end_field - start_field)	 	   ' Extract the data-point's date/time
		   else
		   	  Exit Do
		   end if
		   
		   start_field = end_field+1  			   
		   end_field = instr(start_field, data_string, ",")	   					   ' Find the comma after the voltage, and extract the voltage
		   if end_field > 0 then voltage = mid(data_string, start_field, end_field - start_field)	 
	
	   	   start_field = end_field+1
		   end_field = instr(start_field, data_string, ";")				 		   ' Find the semi-colon after the data-point and extract the current
		   if end_field > 0 then current = mid(data_string, start_field, end_field - start_field)	 
		   start_field = end_field+1
	        
		   if end_field > 0 then		    							 		   ' If we have all of the data for the datapoint, save it in the database					 		   ' 		 		   
			  rsData.AddNew
			  rsData.Fields("IMEI") = imei
			  rsData.Fields("Date") = time
			  rsData.Fields("Voltage") = voltage
			  rsData.Fields("current") = current
			  rsData.Update
		   end if
	    loop while end_field > 0
		
	rsData.Close   			  ' Close the database and destroy the recordset object
	set rsData = nothing
	response.write("OK")	 ' Let the Client know we processed the data - we could add error checking that will report missing data, bad data, etc.
%>
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top