1

I have SQL Server 2008 R2 with a table that contains data ordered by numbers from 1 to 99999.

I want to connect to that table and show the last number of the row in my app, automatically without selecting anything.

How I could do it?

Thanks.

4
  • You cannot do anyting without performing a select statement. Sorry Commented Feb 1, 2012 at 15:10
  • You can use the following select statement Select MAX(MyNumberColumn) FROM MyTable Commented Feb 1, 2012 at 15:11
  • Are you saying that you want to connect to a table in a SQL Server instance on a PC based machine FROM an Android app? Commented Feb 1, 2012 at 15:16
  • possible duplicate of How to connect android to a database server Commented Feb 1, 2012 at 15:19

2 Answers 2

2

If you will connect to the server from your Android App I would recommend using a webservice.

Take a look at this for example:

Rest Webservice

And you don't want to select anything? You can call a Stored Procedure maybe?

Sign up to request clarification or add additional context in comments.

Comments

1

The SQL:

select top 1 from yourtable order by yournumericfield desc; 

Or

select max(yournumericfield) from yourtable; 

I notice that this is tagged Android. Android cannot talk directly with SQL Server. The easiest thing to do is to write a web service to sit in between the Android device and SQL Server:

Android --> Web Service -> SQL Server

You can perform standard HTTP communication in Java to talk to the web service. Your web service can talk to SQL Server using ADO in C++, or using the DB libraries in C#, perhaps. Or easier, using a web scripting language like ASP or ASP.NET, you can use the standard Windows DB functions.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.