|
-
Apr 7th, 2005, 07:48 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] help in simple coding for pda =)
im super newbie in pda development. i've got this:
VB Code:
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Private Sub InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.Button1 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(72, 200)
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.Text = "Button1"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(64, 64)
Me.Label1.Text = "Label1"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(64, 96)
Me.Label2.Text = "Label2"
'
'Form1
'
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button1)
Me.Menu = Me.MainMenu1
Me.Text = "Form1"
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connectionString As String
Dim SQL As String
Dim tmpName As String
Dim tmpCode As String
connectionString = "Server=SQLOLEDB.1; Data Source=DIEVECHNOLOGY; " & _
"Database=test; User ID=sa; Password=;"
Dim conDB As New SqlConnection(connectionString)
SQL = "Select Name, Code from Customers"
Dim comSQL As New SqlCommand(SQL, conDB)
Dim DR As SqlDataReader
Try
conDB.Open()
DR = comSQL.ExecuteReader(CommandBehavior.Default)
While DR.Read
tmpName = DR.GetString(0)
tmpCode = DR.GetValue(1)
Label1.Text = tmpName
Label2.Text = tmpCode
End While
DR.Close()
Catch ex As Exception
MessageBox.Show(Err.Description.ToString)
Finally
conDB.Close()
End Try
End Sub
End Class
anyone got the idea of wat's going on code above?
-
Apr 7th, 2005, 08:23 AM
#2
Fanatic Member
Re: help in simple coding for pda =)
1st of all go to here to help start your learning with vb.net for windows ce
2nd
all of the code above the button1_click is created as part of the form designer when you drag and drop controls onto the form
what the code is doing is connection to a sql server database
VB Code:
connectionString = "Server=SQLOLEDB.1; Data Source=DIEVECHNOLOGY; " & _
"Database=test; User ID=sa; Password=;"
Dim conDB As New SqlConnection(connectionString)
then using a datareader which reads though each row of a table (forward only). Then for each row get the string of column 1 and the valus of column of that row in the table, until there are no more row left
so then close the datareader and the connection
VB Code:
DR = comSQL.ExecuteReader(CommandBehavior.Default)
While DR.Read
tmpName = DR.GetString(0)
tmpCode = DR.GetValue(1)
Label1.Text = tmpName
Label2.Text = tmpCode
End While
DR.Close()
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Apr 7th, 2005, 09:55 AM
#3
Thread Starter
Hyperactive Member
Re: help in simple coding for pda =)
well, i know how wat's the function of the code above, bcoz i wrote it! lol. but it doesn't work, i dunno y. i think must be something wif the database i used. i chose ms sql 7 sp4 as the database, but izzit can use for pda application? or i hav to install something like ms sql CE?
pls guide me, i out of idea already. been trying over n over also cannot success.
-
Apr 7th, 2005, 09:58 AM
#4
Fanatic Member
Re: help in simple coding for pda =)
are you trying to connect to sql server database on the device or a remote sql server database???
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Apr 7th, 2005, 10:08 AM
#5
Thread Starter
Hyperactive Member
Re: help in simple coding for pda =)
ermm, actually im using desktop, vb .net to create the pda application. trying to run in pda emulator, but it givs me error. any suggestion in developing the pda application by using desktop, vb.net? wat kind of database i should use? after successful developed the application, i can transfer to real pda?
-
Apr 7th, 2005, 10:12 AM
#6
Fanatic Member
Re: help in simple coding for pda =)
ok in order to develop application for windows CE you need to develop in Compact Framework.Net which is a reduced("compact") version of VB.net.
You cannot develop and application in vb.net and transfer it accross to the device.
When you create a new project in visual studio you need to select smart device application.
This is only available with Visual Studio 2003 professional
However MS have now made eVB free to download and use, eVB is the predecessor of the compact framework, with a lot less functionality.
eVB however is getting closer and closer to extinction
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Apr 7th, 2005, 10:36 AM
#7
Thread Starter
Hyperactive Member
Re: help in simple coding for pda =)
so i kenot develop the pda application in my ms .net framework wif my vb .net? wat should i do? download the free eVB? then use ms sql ce? currently i don hav a pda yet, but going to get soon. so i just wan to try to develop a pda application in my desktop, pls giv some suggestion to me =)
-
Apr 7th, 2005, 10:51 AM
#8
Fanatic Member
Re: help in simple coding for pda =)
you will need to upgrade your vs2003 so as to get the smart device feature on it.
otherwise you will have to use eVB.
however eVB for win2003 is not that great there are lots of issues and you need to install certain cab files on the device to get eVB to work. as eVB was designed for prior versions of windows ce ie.2000,2002
i would recommend upgrading the vs2003 if you intend developing many application for windows ce as it is the future
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Apr 7th, 2005, 11:06 AM
#9
Thread Starter
Hyperactive Member
Re: help in simple coding for pda =)
i got smart device application in my vs.net2003, i cannot use it to develop pda application? actually the code above was coded under smart device application n it can run in pda emulator provided by vs .net2003. but somehow problem occur in connection, coz im using ms sql 7? instead of ms sql ce. should i install ms sql ce as my smart device application database?
-
Apr 7th, 2005, 11:12 AM
#10
Fanatic Member
Re: help in simple coding for pda =)
As i said.....if you have smart device application you can develop for window ce based PDA's.
Yes it will run in the emulator fine....
if you want to connect to a database on the handheld use sqlce....
if you want to connect to a sql server database use sqlserverce....
have a look for sqlce merge and replication in google for the later...
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Apr 7th, 2005, 11:31 AM
#11
Thread Starter
Hyperactive Member
Re: help in simple coding for pda =)
okies, to further confirm, i can now develop an application for pda but i need to install ms sql ce? is that rite?
-
Apr 7th, 2005, 12:32 PM
#12
Re: help in simple coding for pda =)
Actually, you don't have to DO much of anything. SQLServerCE is closely tied to the CF, and it will be installed automatically when you use it.
Change your connection to Windows.Data.SQLServerCE.SQLCEConnection and SQLServerCE will install next time you run the emulator (or something like that, I actually have never had it not install, so it may be installing anyways, you just aren't using it).
When MS went to .NET CF for mobile app dev, they decided to put out a PDA DBMS that works REALLY tightly with SQLServer. SQLServerCE is that DBMS. You will have a hard time getting away from it, but the good part is that if you are used to working with SQLServer, then SQLServerCE will feel like home.
My usual boring signature: Nothing
 
-
Apr 9th, 2005, 10:32 AM
#13
Thread Starter
Hyperactive Member
Re: help in simple coding for pda =)
now im having difficulties in connecting to SQLServer, where i wan to retrieve data from SQLServer n store into SQLServerCE. well, i don't know much, so far i just know that, to retrieve data from SQLServer, i should transfer the data to SQLServerCE 1st? am i rite?
the code that i don understand :
VB Code:
Dim repl As SqlCeReplication = Nothing
Try
repl = New SqlCeReplication
'Set the properties using data from the UI.
repl.Publisher = "dievechnology"
repl.PublisherLogin = "sa"
'repl.PublisherPassword = " "
repl.InternetUrl = "C:/Inetpub/wwwroot/Sean/sscesa20.dll"
'repl.InternetPassword = " "
repl.Subscriber = "Sean"
repl.Publication = "DIEVECHNOLOGY\Keen"
repl.PublisherDatabase = "Sean"
strDataSource = "\My Documents\Sean"
ssceConn.ConnectionString = "Data Source =" + strDataSource
repl.SubscriberConnectionString = "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=" + strDataSource
'If the file does not exist, create it, and add it as a subscription.
While System.IO.File.Exists(strDataSource) = False
If MessageBox.Show("The file does not exist, do you want to create it?", _
"Merge", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, _
MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
repl.AddSubscription(AddOption.CreateDatabase)
Me.Refresh()
End If
End While
'Synchronize.
repl.Synchronize()
Catch err As SqlCeException
'Add error handling code here.
MessageBox.Show(Err.Message)
Finally
repl.Dispose()
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim repl As SqlCeReplication = Nothing
Try
' Set the Replication object.
repl = New SqlCeReplication
repl.InternetUrl = "C:/Inetpub/wwwroot/Sean/sscesa20.dll"
repl.InternetLogin = "MyLogin"
repl.InternetPassword = " "
repl.Publisher = "dievechnology"
repl.PublisherDatabase = "MyPublisher Database"
repl.PublisherLogin = " "
repl.PublisherPassword = "<MyPublisher Password>"
repl.Publication = "MyPublication"
repl.SubscriberConnectionString = "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\Sean.sdf"
repl.Subscriber = "MySubscriber"
' Mark the subscription for reinitialization with Upload first.
repl.ReinitializeSubscription(True)
' Synchronize to the instance of SQL Server 2000 to populate the Subscription.
repl.Synchronize()
Catch ex As SqlCeException
' Use your own error handling routine to show error information.
' ShowErrors(e)
MessageBox.Show(ex.Message)
Finally
' Dispose of the Replication object.
repl.Dispose()
End Try
hopefully u guys can help in this simple yet difficult problem for me. =)
-
Apr 11th, 2005, 01:03 AM
#14
Thread Starter
Hyperactive Member
Re: help in simple coding for pda =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|