473,325 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

c# - Mobile - Connecting to DB

maxx233
32
Hello,
I'm trying my first application for a mobile device. I'm doing it up for a pocket pc 2003 device, and all this app does is take a value that's in a textbox (a barcode string), and INSERT it into a test DB that has a single table and a single field just for this purpose. When I run it on the virtual pocket PC emulator it works fine, but when it's actually on the hardware device I've got, no go. The device is running off our wireless network, gets an IP, and can make a terminal services connection with the DB server. I can ping the device from my workstation. When I look at SQL profiler I don't see any attempted connections from the device however, but I do see connections from the emulator when I try from there. This is probably something really stupid bear in mind - this is my first *attempt* at a mobile app, and I don't normally work on pocket PC devices either. Any ideas?

Here's my code (I know I *should* be doing SQL paramaters, I'll fix it after I get this working. This is just how I learned and am most comfortable with still, unfortunately):

private void btnSubmit_Click(object sender, EventArgs e)
{
string myQuery = "INSERT INTO Devices (Barcode) VALUES ('" + this.txtBarcode.Text + "');";
string myConnectionString = "Integrated Security=false;" +
"Server=10.3.0.72;" +
"Initial Catalog=testDB;" +
"User Id=theUserName;" +
"Password=thePassword;" +
"connection timeout=30";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand(myQuery, myConnection);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
MessageBox.Show("Yup");
}
catch
{
MessageBox.Show("Nope");
}

}
Mar 31 '08 #1
1 1867
maxx233
32
OK, I solved my own problem. First I hard rebooted, which lost everything on the device. So I reinstalled .NET CF from a cab file located in C:\Program Files\Microsoft .NET\SDK\CompactFramework\v2.0\WindowsCE, which was different from my previous install (I believe.. it was pre-existing on the device when I got it)

Then I added an exception to my catch block so I could see the error it was pulling up, and either as a result of that, or as a result of the different version of compact framework, I got something like: "can't find PInvoke DLL 'dbnetlib.dll'", which a quick google search found this , which basically says to install the sqlclient from C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Client\v2.0

Did that and problem solved. Thanks to anyone who thought about it though!

Maxx

Hello,
I'm trying my first application for a mobile device. I'm doing it up for a pocket pc 2003 device, and all this app does is take a value that's in a textbox (a barcode string), and INSERT it into a test DB that has a single table and a single field just for this purpose. When I run it on the virtual pocket PC emulator it works fine, but when it's actually on the hardware device I've got, no go. The device is running off our wireless network, gets an IP, and can make a terminal services connection with the DB server. I can ping the device from my workstation. When I look at SQL profiler I don't see any attempted connections from the device however, but I do see connections from the emulator when I try from there. This is probably something really stupid bear in mind - this is my first *attempt* at a mobile app, and I don't normally work on pocket PC devices either. Any ideas?

Here's my code (I know I *should* be doing SQL paramaters, I'll fix it after I get this working. This is just how I learned and am most comfortable with still, unfortunately):

private void btnSubmit_Click(object sender, EventArgs e)
{
string myQuery = "INSERT INTO Devices (Barcode) VALUES ('" + this.txtBarcode.Text + "');";
string myConnectionString = "Integrated Security=false;" +
"Server=10.3.0.72;" +
"Initial Catalog=testDB;" +
"User Id=theUserName;" +
"Password=thePassword;" +
"connection timeout=30";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand(myQuery, myConnection);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
MessageBox.Show("Yup");
}
catch
{
MessageBox.Show("Nope");
}

}
Mar 31 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jose Gonzalez | last post by:
How to apply a numeric format to a textbox using xhtml? I know you have to use the "-wap-input-format" style tag in css. I can get this to work in a regular xhtml page, however, I've been...
0
by: Wiktor Zychla | last post by:
Hi there, I've just started to dig into mobile ASP.NET and I'd really wish to clarify few things. I have the experience with ASP.NET. 1) Some tutorials mention something called Microsoft...
3
by: vul | last post by:
I've got a request from my boss to give some users the ability to connect to SQL Server database while they are on the road. I'm VB6 and VB.Net (beginner) developer. Mobile devices were not bought...
3
by: meo | last post by:
Can I use Visual Studio 2005 (VB.NET) develop WAP site? I cannot see the mobile control or any template like a Visual Studio.NET.
1
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have Mobile site that I'm building. My problem is that all of my pages are built as Mobile ASPX pages, but occasionally, I need to use controls which are not mobile. Most specifically, the...
0
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
Like many people, I normally use Yahoo! Mail via the web and like to keep all my emails stored on the Yahoo! server. However sometimes I can’t get access to a PC/the web and I download my emails...
4
by: =?Utf-8?B?TUpTVmlraW5n?= | last post by:
It looks like one should be able to connect to a Cisco VPN using the native Mobile 5 IPsec connection option. Alas, I cannot get it to work and web searches turn up multiple messages where others...
0
by: =?Utf-8?B?VmVyb25pY2E=?= | last post by:
I have been utilizing the Mobile Service for the past 12 months or so with no problems. Over the past week I am no longer able to send text messages without the following occuring: ...
0
by: ezrockgw | last post by:
i want to make an application in j2me so that it interacts with database and keeps updating it. How can i connect my mobile to the pc which has the database?...Will it be through bluetooth which i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.