index > SQL Server Everywhere Edition > Working with data in a mobile solution

Working with data in a mobile solution

Im doing a project using VS2k5 and sql server2k5. Its a mobile project and this is my first time working with SQL and Visual Basic. I need to know how to add data to my database from the windows form.I have however been able to use the tableadapters and some sql statements to read data from the database in my forms. Can anyone here help me?
Horator24

You can either write the SQL yourself to insert data into SQL Server 2005 Mobile Edition or you can leverage data binding on your form to update the underlying database automatically. You should review the programming guide for SQL Mobile and the IBuySpyStore sample application for examples of how to do this.

http://msdn2.microsoft.com/en-us/library/ms173041(SQL.90).aspx

-Darren




.NET Compact Framework MVP
Darren Shaffer
I prefer using the form to update the database, but before i go any further let me try to explain a little bit better as to what im trying to accomplish. I want a database on the pocket pc itself and a copy on the home machine as to facilitate easier data entry. The data would sync the next time the machine is connected to said machine. My solution does not have an online component to it but never the less i found the premise of the iBuySpy solution to have elements i could use, there is just one problem, i cannot install the solution, it is telling me i do not have SQL on my machine, which of course is not the case.With that said most of the examples there i see have to deal with online solutions, mine is not. How do i add data to my database using the forms I have?
Horator24

Well, forms do not update databases, code does. If your form has a textbox control on it called "Last Name", your options are to use data binding on this control to persist whatever the user enters in this control or to write code that uses System.Data.SqlServerCe namespace classes to perform the select/insert/update yourself.

The SqlCeCommand class contains ExecuteQuery and ExecuteNonQuery methods which take SQL which can be run against SQL Mobile.

Before you try to do any data binding, I recommend learning how to get data from and insert/update data to a SQL Mobile database using code (ADO.NET and SQL) - that way you can understand what is going on with the binding and tune the SQL statements that the BindingSource (DataSetGenerator or ResultSetGenerator) create for you.

-Darren




.NET Compact Framework MVP
Darren Shaffer
Well ive looked into your suggestion, but im gettin more confused than ever, but i did unearth something in my reading. These table adapters are able to insert data to the database via stored procedures. My question is how would I get a insert statement to associate itself with a string in a textbox?
Horator24

The concept I think you are chasing down is called Data Binding in the Microsoft .NET world. The technical coverage of Data Binding in the .NET Compact Framework can be found here:

http://msdn2.microsoft.com/en-us/library/9k8yax26(VS.80).aspx

Many controls in the .NET Compact Framework have a DataSource member that supports binding to a DataTable which you can obtain with a table adapter, binding source, or for read-only simple binding, by filling a DataTable using a SqlCeDataReader as shown below:

Dim dt As DataTable = DatabaseManager.GetInstance().GetDataTable("SELECT ID, Name FROM Technician WHERE Status = 'Active'")

Me.cboTechnician.DataSource = dt

Me.cboTechnician.DisplayMember = "Name"

Me.cboTechnician.ValueMember = "ID"

Simply by setting the cboTechnician combobox's datasource, display and value members, this control is populated by the underlying DataTable and you have the unique ID of each value available without a subsequent round trip to the database.

A newsgroup is not the best place to teach data binding - I recommend a copy of either Paul Yao's book .NET Compact Framework Programming with C# (or VB.NET) or the MSDN Press book .NET Compact Framework Core Reference by Andy Wigley. Both offer excellent coverage of this topic.

-Darren




.NET Compact Framework MVP
Darren Shaffer
reply 6

You can use google to search for other answers

 

More Articles

• CE upgrade tool?
• How to add data in sql mobile database from sql server 2005 manag...
• VB.Net CF App falls over on SqlServerCe ExecuteNonQuery under WM5...
• Convert SQLExpress db to Sql Anywhere
• Getting RecordCount with TableDirect
• NEED HELP - Merge Replication with SQL Server 2000
• I have the same problem
• Creating PK/FK Relationship
• SQL Server 2005 Everywhere Edition: Replication with MS Access?
• Synchronize SQL Mobile 2005 using ActiveSync
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• How to convert SDF to XML?
• Not all subscriber types in New Subscrip
• Can someone clarify why only a single-st
• RDA pull - from a temporary table
• Datasource cannot connect in vs2005
• parameterized query that counts the numb
• HELP US MICROSOFT: SYNCH BETWEEN SQL EX
• cannot P/Invoke SQLCEME30.DLL when debug
• ADO
• [SQLCE Mobile]Do Select during Transaction
• Accessing SQL Mobile Databases in VB2005
• SSev and Enterprise Library
• Setting up Sql Mobile subscription
• a strange RDA problem
• Very newbie question

Hot Articles

• RAPI, CCeDBDatabase, EDB, CEDB, and the
• SOS, please help
• rda localconnection
• SQL Mobile query hangs PPC 2003 device
• Extracting Data from SQL CE SDF file
• how to make Pocket PC synchronization se
• unable to connect to SQL Everywhere in V
• RDA pull - from a temporary table
• ibuyspy 2005 distribution sample: missin
• Everywhere Edition and VS Express
• SQL CE table creation with Mobile Query
• SQL Mobile 2005 Replication - SQL Mobile
• Couldn't find a record in SQL Server 200
• Create .SDF from .MDF File
• Problem in using EDB

Recommend Articles

• SQL Server Mobile and isqlw20
• Help setting up replication on remote IIS
• RE: SQL Mobile Get Started Tutorial
• Query:how to transfer data from a .net a
• SQL CE Installation Location
• ANN: VistaDB 3 as world's first managed
• RDA Pull method not creating tables/inse
• SQL Everywhere SLSErver to SQLEv without
• Merge Replication Without Merging Client
• DateTime.Min won't insert into SQL Serve
• SQL Mobile - Locale Not supported
• RDA.Pull and INNER JOINS...
• Synchronizing Very Large Database from P
• Newbie: Am I really using Everywhere?
• Connection String Encryption for SQL Ser