Accessing SQL server Database - Windows Mobile Software Development

So I am trying to access a data an sql database hosted by godaddy.com i am easily able to write to and read from the database from a desktop app the i wrote but i was trying to write an app for my windows moible phone that would write to the database but its not working. I don't get any errors, the program just runs but nothing get written to the database. Any help would be great. Thanks
Code:
string connectionstring = "data Source=irus99.db.5497838.hostedresource.com;Initial Catalog=irus99;Persist Security Info=True;User ID=usr;Password=pw";
SqlConnection connection = new SqlConnection(connectionstring);
string insertStatement = "INSERT Data (User, ZipCode, LatLong) " + "VALUES (@User, @ZipCode, @LatLong)";
SqlCommand insertCommand = new SqlCommand(insertStatement, connection);
connection.Open();
insertCommand.Parameters.AddWithValue("@User", "name");
insertCommand.Parameters.AddWithValue("@ZipCode", 32826);
insertCommand.Parameters.AddWithValue("@LatLong", 28.59283);
connection.Close();

no one knows...

........

Calling
Code:
insertCommand.ExecuteNonQuery();
before closing the connection?

heliosdev said:
Calling
Code:
insertCommand.ExecuteNonQuery();
before closing the connection?
Click to expand...
Click to collapse
Thanks for replying, I tried what you said but I get an error. I put the insertCommand.ExecuteNonQuery(); right after the other insert commands. do you have another suggestion. Thanks again

You put the line just before closing the connection, right?
Do you check that the connection is open after the connection.Open() call?

heliosdev said:
You put the line just before closing the connection, right?
Do you check that the connection is open after the connection.Open() call?
Click to expand...
Click to collapse
how can i check?, I just assumed that it was since i was not getting any errors

check connection.State == ConnectionState.Open
P.S.:
What cf version are you using? (2.0, 3.5)
I'm using SqlCeConnection and you have SqlConnection

heliosdev said:
check connection.State == ConnectionState.Open
P.S.:
What cf version are you using? (2.0, 3.5)
I'm using SqlCeConnection and you have SqlConnection
Click to expand...
Click to collapse
I tried SqlCeConnection but I was getting errors. I'm using 3.5

Is check a command cause its not showing up???

Code:
...
connection.Open();
if (connection.State == ConnectionState.Open)
{
...
connection.Close();
}
...

heliosdev said:
Code:
...
connection.Open();
if (connection.State == ConnectionState.Open)
{
...
connection.Close();
}
...
Click to expand...
Click to collapse
I get an error
'System.Data.ConnectionState' is a 'type' but is used like a 'variable'

Related

HELP! Running external program process minimized using .NET

I'm stumped on how to do this...
I'm trying to call an external program (python CE) in my vb.net program to run a script. I'm using the following code and it works just fine... EXCEPT that it opens python.exe in the foreground, processes my script in an open window and closes it. I want the whole process to be invisible to the user. Python CE does not have a (working) console-less function, so I need to try to do it using .NET.
I can't figure it out!
Code:
Dim scriptfile As String
Dim pyProcess As New Process()
scriptfile = """\default.pyw"" ""1"" ""2"""
pyProcess.StartInfo.FileName = "\Program Files\Python25\python.exe"
pyProcess.StartInfo.Arguments = scriptfile
pyProcess.StartInfo.UseShellExecute = False
pyProcess.Start()
As you can see the UseShellExecute property set to false does nothing. Should I maybe try running this in a separate thread??
Here you have an example of how it should look like
Code:
Public Sub HTCRomTool(ByVal localeID As String)
Dim process As New Process
process.StartInfo.Arguments = (" /buildrom "".\FLASH\ferom.htcrtproj"" "".\FLASH\RUU_Signed_" & localeID & ".nbh""")
process.StartInfo.FileName = (Me.ToolsFolder & "\htcrt.exe")
process.StartInfo.CreateNoWindow = True
process.Start
Do While Not process.HasExited
Thread.Sleep(100)
Loop
process.Close
process.Dispose
End Sub
That you need to add your references and arguments
I appreciate it! and will try it out ASAP
CreateNoWindow does not show up as a member of system.diagnostics.process.StartInfo...
I'm using NET CF 3.5 and VS2008 refuses to accept that line.
The next example, the NET CF 3.5 and VS2008
Code:
Dim p As New Process()
p.UseShellExecute = True
p.StartInfo.FileName = "C:\Windows\Notepad.exe"
p.StartInfo.Verb = "runas"
p.Start()
And See This - Open NetCF
nokser said:
The next example, the NET CF 3.5 and VS2008
Code:
Dim p As New Process()
p.UseShellExecute = True
p.StartInfo.FileName = "C:\Windows\Notepad.exe"
p.StartInfo.Verb = "runas"
p.Start()
Click to expand...
Click to collapse
I appreciate the help, but that doesn't stop pythonCE from launching in its own window. I'm going to reinstall the SDKs just in case I screwed something up a while ago... other than that, I'll have to think on it.
OpenNetCF is interesting but the newest version (2.X) doesn't have the Process namespace anymore. They took it out with the advent of NET CF 2.0. I might try their deprecated version though (1.4)
For anyone else that is interested in this thread, I figured out a solution.
PythonCE does work on WM6.5 and the switch to run without a console/window opening is /nopcceshell.
HOWEVER, this won't work on the emulator that's part of VS2008 when you're debugging your software! If you use your own device on ActiveSync and debug your program on your physical device, it actually works. I'm running WM6.5.4 (I think).
There's no special code needed to run this in VB.NET... just start a process and pass "/nopcceshell" as the first argument. Then you can put your script name (needs full path) and any other arguments afterwards.
Oh man this was killing me.... SOLVED!

Connecting to an sql database

I am trying to write data to a data base from my phone but for some reason it does not write to the data base but i don't get any errors so im not sure what to do next. any help would be great. Thanks
Code:
string connectionstring = "Data Source=irus99.db.5497838.hostedresource.com;Initial Catalog=irus99;Persist Security Info=True;User ID=*****;Password=*******";
SqlConnection connection = new SqlConnection(connectionstring);
connection.Open();
string insertStatement = "INSERT Data (User, ZipCode, LatLong) " + "VALUES (@User, @ZipCode, @LatLong)";
SqlCommand insertCommand = new SqlCommand(insertStatement, connection);
insertCommand.Parameters.AddWithValue("@User", "Joe");
insertCommand.Parameters.AddWithValue("@ZipCode", strZip);
insertCommand.Parameters.AddWithValue("@LatLong", latitudine);
connection.Close();
irus said:
I am trying to write data to a data base from my phone but for some reason it does not write to the data base but i don't get any errors so im not sure what to do next. any help would be great. Thanks
Code:
string connectionstring = "Data Source=irus99.db.5497838.hostedresource.com;Initial Catalog=irus99;Persist Security Info=True;User ID=*****;Password=*******";
SqlConnection connection = new SqlConnection(connectionstring);
connection.Open();
string insertStatement = "INSERT Data (User, ZipCode, LatLong) " + "VALUES (@User, @ZipCode, @LatLong)";
SqlCommand insertCommand = new SqlCommand(insertStatement, connection);
insertCommand.Parameters.AddWithValue("@User", "Joe");
insertCommand.Parameters.AddWithValue("@ZipCode", strZip);
insertCommand.Parameters.AddWithValue("@LatLong", latitudine);
connection.Close();
Click to expand...
Click to collapse
Have you checked to make sure the connection has been successful?
Can you READ from the database?
You could try just creating a Typed DataSet...
I did a similar project but cheated in a way, by using a php page on the remote host to act as a gateway for the specific requests I needed the mobile device to make. It worked pretty well, and meant that I just needed to use the .NET Http object for the request and response.
Moved as not software release.

Class 0 SMS (flash SMS) on Android 2.1+

Hi!
Have anyone noticed that Android removed the hidden API sendRawPdu() from the Interface ISms?
androidjavadoc.com/1.0_r1_src/com/android/internal/telephony/gsm/ISms.html
(I'm not allowed to link yet because I'm a new user ).
The API was still present at 1.6.
Is there a way to implement this into a custom ROM so that we could keep continuing to send these class 0 SMS'? Or is there a new method that I've missed?
Cheers
Flash SMS works fine for me.
Not very polished application, but does correctly send flash SMS.
snark_be said:
Flash SMS works fine for me.
Not very polished application, but does correctly send flash SMS.
Click to expand...
Click to collapse
I was under the impression that "FlashSMS" did *not* work with newer Android releases. At least that what I've read about it. The main reason why I'm pursuing this is because MyPhoneExplorer lost it's capability to send class 0 SMS through the phone (after v1.6) due to Android removing the API completely. And it shouldn't be too hard to implement this API in a custom ROM? Anyone?
itwt said:
I was under the impression that "FlashSMS" did *not* work with newer Android releases. At least that what I've read about it. The main reason why I'm pursuing this is because MyPhoneExplorer lost it's capability to send class 0 SMS through the phone (after v1.6) due to Android removing the API completely. And it shouldn't be too hard to implement this API in a custom ROM? Anyone?
Click to expand...
Click to collapse
Just bought it, didn't work for my, Defrost 5.7.. tried both with regular number and with +46 (my country prefix..) refund!
itwt said:
I was under the impression that "FlashSMS" did *not* work with newer Android releases.
Click to expand...
Click to collapse
As sais above, it works for me, on a HTC Desire running a rooted Froyo.
ivarson_swe said:
Just bought it, didn't work for my, Defrost 5.7.. tried both with regular number and with +46 (my country prefix..) refund!
Click to expand...
Click to collapse
Did the application crash? Or is the Flash SMS not sent? Maybe it's your operator that blocks Flash SMSes?
Flash sms works for me too, the one made by qwinter......
Sent from my HTC Desire using Tapatalk
Hmm, strange.. I wonder what API he used. I might try that app.
I'm still up for implementing the API mentioned, though.
snark_be said:
As sais above, it works for me, on a HTC Desire running a rooted Froyo.
Did the application crash? Or is the Flash SMS not sent? Maybe it's your operator that blocks Flash SMSes?
Click to expand...
Click to collapse
Nothing happened when I hit send. No crash or message. Should have checked logcat, too late now though.. you could be right about lockdown by operator too.. haven't tried sending from that sim card befo..
ivarson_swe said:
Just bought it, didn't work for my, Defrost 5.7.. tried both with regular number and with +46 (my country prefix..) refund!
Click to expand...
Click to collapse
Did you get an error or what happened? I just got "SMS send end" popup when I tried to press the send button.
EDIT:
Nevermind, it worked.
itwt said:
Did you get an error or what happened? I just got "SMS send end" popup when I tried to press the send button.
EDIT:
Nevermind, it worked.
Click to expand...
Click to collapse
the sms send end popup means the sms has been sent lol
AndroHero said:
the sms send end popup means the sms has been sent lol
Click to expand...
Click to collapse
Not necessarily, as mine didn't send because I activated flight mode, yet the popup appeared.
I just spoke with the author, he's calling the SendRawPdu() method to push the class 0 sms through. So the API must be present in the system after all. Hmm.
IS the API still here cause i can't use/find it
Flash sms
Flash sms - nothing happend when i hit SEND
Advansed sms sender - "send failed"
HTC Tattoo with 2.3.3 CM7
Still no luck with class0 on Android? Something like HushSMS would be great!
I think the code is missing is the following, that exists in the previous version 2:
grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.6_r2/com/android/internal/telephony/IccSmsInterfaceManager.java#IccSmsInterfaceManager.sendRawPdu(byte%5B%5D%2Cbyte%5B%5D%2Candroid.app.PendingIntent%2Candroid.app.PendingIntent[/url])
/**
* Send a Raw PDU SMS
*
* @param smsc the SMSC to send the message through, or NULL for the
* defatult SMSC
* @param pdu the raw PDU to send
* @param sentIntent if not NULL this <code>Intent</code> is
* broadcast when the message is sucessfully sent, or failed.
* The result code will be <code>Activity.RESULT_OK<code> for success,
* or one of these errors:
* <code>RESULT_ERROR_GENERIC_FAILURE</code>
* <code>RESULT_ERROR_RADIO_OFF</code>
* <code>RESULT_ERROR_NULL_PDU</code>.
* @param deliveryIntent if not NULL this <code>Intent</code> is
* broadcast when the message is delivered to the recipient. The
* raw pdu of the status report is in the extended data ("pdu").
*/
public void sendRawPdu(byte[] smsc, byte[] pdu, PendingIntent sentIntent,
PendingIntent deliveryIntent) {
Context context = mPhone.getContext();
context.enforceCallingPermission(
"android.permission.SEND_SMS",
"Sending SMS message");
if (DBG) log("sendRawPdu: smsc=" + smsc +
" pdu="+ pdu + " sentIntent" + sentIntent +
" deliveryIntent" + deliveryIntent);
mDispatcher.sendRawPdu(smsc, pdu, sentIntent, deliveryIntent);
}
create SmsRawData lists from all sms record byte[] Use null to indicate "free" record
Parameters:
messages List of message records from EF_SMS.
Returns:
SmsRawData list of all in-used records
121
122 protected ArrayList<SmsRawData> buildValidRawData(ArrayList<byte[]> messages) {
123 int count = messages.size();
124 ArrayList<SmsRawData> ret;
125
126 ret = new ArrayList<SmsRawData>(count);
127
128 for (int i = 0; i < count; i++) {
129 byte[] ba = messages.get(i);
130 if (ba[0] == STATUS_ON_ICC_FREE) {
131 ret.add(null);
132 } else {
133 ret.add(new SmsRawData(messages.get(i)));
134 }
135 }
136
137 return ret;
138 }
Generates an EF_SMS record from status and raw PDU.
Parameters:
status Message status. See TS 51.011 10.5.3.
pdu Raw message PDU.
Returns:
byte array for the record.
146
147 protected byte[] makeSmsRecordData(int status, byte[] pdu) {
148 byte[] data = new byte[IccConstants.SMS_RECORD_LENGTH];
149
150 // Status bits for this record. See TS 51.011 10.5.3
151 data[0] = (byte)(status & 7);
152
153 System.arraycopy(pdu, 0, data, 1, pdu.length);
154
155 // Pad out with 0xFF's.
156 for (int j = pdu.length+1; j < IccConstants.SMS_RECORD_LENGTH; j++) {
157 data[j] = -1;
158 }
159
160 return data;
161 }
162
163 protected abstract void log(String msg);
164
165}
Compared with the 2.2.1_r1
grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/1.6_r2/com/android/internal/telephony/IccSmsInterfaceManager.java/?v=diff&id2=2.2.1_r1
Working app
Only for HTC official ROMs, but working. Available in Market. Application name - "Flash sms for HTC"
Flash SMS by jomegasoft in the market works on my HTC Sensation Z710a running Pyramid3D v8.3.0 XE ROM.
hi there, ive tried all the applications!
Flash sms (logo with heart)
Flash sms (Jomego)
HushSMS
advanced sms sender and ...
and all above DOES NOT send class 0 sms for me
and there is one apk that i can not try!
https://github.com/virtualabs/ZeroSMS
can any body tell me how can i install that?
ive tried with Quick ADB Pusher v0.5 but i can not do that!
DSH said:
hi there, ive tried all the applications!
Flash sms (logo with heart)
Flash sms (Jomego)
HushSMS
advanced sms sender and ...
and all above DOES NOT send class 0 sms for me
and there is one apk that i can not try!
can any body tell me how can i install that?
ive tried with Quick ADB Pusher v0.5 but i can not do that!
Click to expand...
Click to collapse
Hi click on the first folder or top folder then select the signed apk and install. Works perfectly with my nexus 4 running minco ROM and Franco kernel r53
---------- Post added at 09:00 PM ---------- Previous post was at 08:54 PM ----------
I used root browser lite to install and download it apk using my phone .if I remember correctly go root browser
Sdcard/ download/ and install from there.

[Q] [Win 8 JS dev] Uglified, Concated, UTF-8 + BOM encoded JS files for a Windows App

Hey everybody,
I'm currently porting my company's webapp to Windows 8. As being written 99% in JavaScript, I just started a new Windows Store JS App project in Visual Studio and moved all of my code in. After some fixes, the app is running fine now.
For deployment, I'm using grunt with grunt-contrib-uglify to concat and minify my JS files. They are saved with UTF-8 encoding und the windows app runs fine using those minified scripts. But the WACK certification fails because those files don't contain the BOM (Byte Order Marker).
I now added a step to my grunt setup, which adds the BOM to those JS files by reading the filecontent as buffer and re-save it with \uFFEF (the BOM) at the beginning. That leads to correctly encoded files, passing the certification.
The funny part is:
When I run the app as Debug or Release right from VS (with debugger), the app is working fine.
If I bundle the app for store submit and start it with the debugger attached, it's also running fine. But if I start the app without the debugger, the scripts are not being loaded.
Do you have a tip for me?
ice8lue said:
Hey everybody,
I'm currently porting my company's webapp to Windows 8. As being written 99% in JavaScript, I just started a new Windows Store JS App project in Visual Studio and moved all of my code in. After some fixes, the app is running fine now.
For deployment, I'm using grunt with grunt-contrib-uglify to concat and minify my JS files. They are saved with UTF-8 encoding und the windows app runs fine using those minified scripts. But the WACK certification fails because those files don't contain the BOM (Byte Order Marker).
I now added a step to my grunt setup, which adds the BOM to those JS files by reading the filecontent as buffer and re-save it with \uFFEF (the BOM) at the beginning. That leads to correctly encoded files, passing the certification.
The funny part is:
When I run the app as Debug or Release right from VS (with debugger), the app is working fine.
If I bundle the app for store submit and start it with the debugger attached, it's also running fine. But if I start the app without the debugger, the scripts are not being loaded.
Do you have a tip for me?
Click to expand...
Click to collapse
Build project as release and THEN create the app package check for breakpoints. Also does it run uncompressed?
Can you provide the code or the package?
Toxickill said:
Build project as release and THEN create the app package check for breakpoints. Also does it run uncompressed?
Click to expand...
Click to collapse
Doesn't the Package process do the build on it's own?
It is working when I load all the single JS files (that grunt is merging into one) and add the BOM to all of them. If I just concat those files without compression/minification it's working, together with the added BOM it's not...
There are no errors (I added an error listener), they simply don't get loaded.
---
I tried your solution, but it ends the same. The interesting part is, if I use publish rather than build, it gets installed und IS running without a debugger. After packaging, it's not...
The marker you are adding is for the UTF format MS uses... However you are encoding to UTF-8...
Toxickill said:
The marker you are adding is for the UTF format MS uses... However you are encoding to UTF-8...
Click to expand...
Click to collapse
This is, basically, what I'm doing to those JS files after concat/minify:
Code:
var buf = grunt.file.read(fileName, { encoding: null });
var missingBOM = (buf[0] !== 0xEF && buf[1] !== 0xBE && buf[2] !== 0xBB);
if (missingBOM) {
grunt.file.write(fileName, '\ufeff' + buf, { encoding: 'utf-8' });
}
See here http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx
Im mobile so im sorry for link.. But you are using the wrong marker for the encoding see here for a table.
Toxickill said:
See here http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx
Im mobile so im sorry for link.. But you are using the wrong marker for the encoding see here for a table.
Click to expand...
Click to collapse
Hmm... but it's the same marker as VS adds when I'm manually saving them with UTF8-signed encoding. EF BB BF adds cryptical symbols but no BOM...
Can you create me a blank program compress it and send it to me so i can see if it does not work and i ca debug it as well.
Toxickill said:
Can you create me a blank program compress it and send it to me so i can see if it does not work and i ca debug it as well.
Click to expand...
Click to collapse
I'm sorry, I can't give out the code...
This is essentially what it does:
HTML:
HTML:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<link rel="stylesheet" href="%dest%css/%lib-css%" />
<link rel="stylesheet" href="%dest%css/%app-css%" />
</head>
<body>
<div id="wrapper"></div>
<script>
var script = document.createElement('script');
script.async = false;
script.type="text/javascript";
script.charset = "utf-8";
script.onload = function() {
...
};
script.src = '%dest%js/%libs-js%';
document.head.appendChild(script);
var script = document.createElement('script');
script.async = false;
script.type="text/javascript";
script.charset = "utf-8";
script.onload = function() {
... (initialize app,...)
};
script.src = '%dest%js/%app-js%';
document.head.appendChild(script);
</script>
</body>
</html>
What my grunt script does is minify all JS files into app.js and libs.js, the CSS into app.css and libs.css and replace the %var% variables with the corresponding files/folders.
My script now writes the correct BOM to the file and also removes possible BOMs in the file left from the source files during merging:
Code:
var buf = grunt.file.read(dist + fileName, { encoding: null });
var BOM = new Buffer([0xEF,0xBB,0xBF]);
// remove multi BOMs from Buffer
var bufString = buf.toString('utf-8');
bufString = bufString.replace(BOM.toString('utf-8'), null);
buf = new Buffer(bufString, 'utf-8');
// add new UTF-8 BOM to the beginning of the file buffer
var bomFile = Buffer.concat([BOM,buf]);
grunt.file.write(dist + fileName, bomFile, { encoding: 'utf-8' });
I double-checked via a HEX editor that the resulting files 1. contain the correct BOM at the beginning and 2. don't contain any additional BOMs (neither the UTF8 nor the THF16 one).
Still, no luck launching the app without a debugger, my JS is not loaded/parsed...
No ideas guys?
ice8lue said:
No ideas guys?
Click to expand...
Click to collapse
Sorry, ive been working the 8.1 jailbeak, try keeping your scrips in the same directory and referencing them with the file name only...
This could be the problem....
Code:
%dest%js/%libs-js%
Im not familiar with JS windows store apps.
Toxickill said:
Sorry, ive been working the 8.1 jailbeak, try keeping your scrips in the same directory and referencing them with the file name only...
This could be the problem....
Code:
%dest%js/%libs-js%
Im not familiar with JS windows store apps.
Click to expand...
Click to collapse
No problem in general, but we're eager to release the app.
The code path is correct, these are variables, being overwritten during deployment.
Update:
It looks like it's really the combination of merged JS files by uglifyJS and the BOM that causes this problem. I now disabled the merge, loading all of the files seperately (but in a minified form) with the BOM added. The app now succeeds certification AND is running without a debugger.
This is ugly, but it's working - finally.

Reading a file from /data/data

I'm trying to read the list of active Xposed modules at "/data/data/de.robv.android.xposed.installer/conf/modules.list"
Currently, I'm using
Code:
String line;
process = new ProcessBuilder("su", "-c", "cat", MODULES_LIST_FILE).start();
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = in.readLine()) != null) {
modules.add(line);
}
in.close();
- which does work, I'd just prefer to not require root access.
Where could I possibly hook to give me access to this file?
Thanks!
arilotter said:
I'm trying to read the list of active Xposed modules at "/data/data/de.robv.android.xposed.installer/conf/modules.list"
Currently, I'm using
Code:
String line;
process = new ProcessBuilder("su", "-c", "cat", MODULES_LIST_FILE).start();
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = in.readLine()) != null) {
modules.add(line);
}
in.close();
- which does work, I'd just prefer to not require root access.
Where could I possibly hook to give me access to this file?
Thanks!
Click to expand...
Click to collapse
I believe that the "android" package has access to all data. So you could hook handleLoadPackage, wait for the "android" package to load, then try reading your file. Not sure if it'd work or not, though. You wouldn't have to hook any specific method.

Categories

Resources