Results 1 to 14 of 14

Thread: [RESOLVED] help in simple coding for pda =)

  1. #1

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Resolved [RESOLVED] help in simple coding for pda =)

    im super newbie in pda development. i've got this:
    VB Code:
    1. Imports System.Data.SqlClient
    2.  
    3. Public Class Form1
    4.     Inherits System.Windows.Forms.Form
    5.     Friend WithEvents Button1 As System.Windows.Forms.Button
    6.     Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    7.  
    8. #Region " Windows Form Designer generated code "
    9.  
    10.     Public Sub New()
    11.         MyBase.New()
    12.  
    13.         'This call is required by the Windows Form Designer.
    14.         InitializeComponent()
    15.  
    16.         'Add any initialization after the InitializeComponent() call
    17.  
    18.     End Sub
    19.  
    20.     'Form overrides dispose to clean up the component list.
    21.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    22.         MyBase.Dispose(disposing)
    23.     End Sub
    24.  
    25.     'NOTE: The following procedure is required by the Windows Form Designer
    26.     'It can be modified using the Windows Form Designer.  
    27.     'Do not modify it using the code editor.
    28.     Friend WithEvents Label1 As System.Windows.Forms.Label
    29.     Friend WithEvents Label2 As System.Windows.Forms.Label
    30.     Private Sub InitializeComponent()
    31.         Me.MainMenu1 = New System.Windows.Forms.MainMenu
    32.         Me.Button1 = New System.Windows.Forms.Button
    33.         Me.Label1 = New System.Windows.Forms.Label
    34.         Me.Label2 = New System.Windows.Forms.Label
    35.         '
    36.         'Button1
    37.         '
    38.         Me.Button1.Location = New System.Drawing.Point(72, 200)
    39.         Me.Button1.Size = New System.Drawing.Size(80, 24)
    40.         Me.Button1.Text = "Button1"
    41.         '
    42.         'Label1
    43.         '
    44.         Me.Label1.Location = New System.Drawing.Point(64, 64)
    45.         Me.Label1.Text = "Label1"
    46.         '
    47.         'Label2
    48.         '
    49.         Me.Label2.Location = New System.Drawing.Point(64, 96)
    50.         Me.Label2.Text = "Label2"
    51.         '
    52.         'Form1
    53.         '
    54.         Me.Controls.Add(Me.Label2)
    55.         Me.Controls.Add(Me.Label1)
    56.         Me.Controls.Add(Me.Button1)
    57.         Me.Menu = Me.MainMenu1
    58.         Me.Text = "Form1"
    59.  
    60.     End Sub
    61.  
    62. #End Region
    63.  
    64.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    65.  
    66.         Dim connectionString As String
    67.         Dim SQL As String
    68.         Dim tmpName As String
    69.         Dim tmpCode As String
    70.  
    71.         connectionString = "Server=SQLOLEDB.1; Data Source=DIEVECHNOLOGY; " & _
    72.                            "Database=test; User ID=sa; Password=;"
    73.  
    74.         Dim conDB As New SqlConnection(connectionString)
    75.         SQL = "Select Name, Code from Customers"
    76.  
    77.         Dim comSQL As New SqlCommand(SQL, conDB)
    78.         Dim DR As SqlDataReader
    79.  
    80.         Try
    81.             conDB.Open()
    82.             DR = comSQL.ExecuteReader(CommandBehavior.Default)
    83.  
    84.             While DR.Read
    85.                 tmpName = DR.GetString(0)
    86.                 tmpCode = DR.GetValue(1)
    87.                 Label1.Text = tmpName
    88.                 Label2.Text = tmpCode
    89.             End While
    90.  
    91.             DR.Close()
    92.         Catch ex As Exception
    93.             MessageBox.Show(Err.Description.ToString)
    94.         Finally
    95.             conDB.Close()
    96.         End Try
    97.  
    98.     End Sub
    99. End Class

    anyone got the idea of wat's going on code above?
    *wink wink*

    _babyekc

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    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:
    1. connectionString = "Server=SQLOLEDB.1; Data Source=DIEVECHNOLOGY; " & _
    2.                            "Database=test; User ID=sa; Password=;"
    3.  
    4.         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:
    1. DR = comSQL.ExecuteReader(CommandBehavior.Default)
    2.  
    3.             While DR.Read
    4.                 tmpName = DR.GetString(0)
    5.                 tmpCode = DR.GetValue(1)
    6.                 Label1.Text = tmpName
    7.                 Label2.Text = tmpCode
    8.             End While
    9.  
    10.             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

  3. #3

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    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.
    *wink wink*

    _babyekc

  4. #4
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    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

  5. #5

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    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?
    *wink wink*

    _babyekc

  6. #6
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    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

  7. #7

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    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 =)
    *wink wink*

    _babyekc

  8. #8
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    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

  9. #9

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    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?
    *wink wink*

    _babyekc

  10. #10
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    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

  11. #11

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    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?
    *wink wink*

    _babyekc

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    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

  13. #13

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    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:
    1. Dim repl As SqlCeReplication = Nothing
    2.  
    3.         Try
    4.  
    5.             repl = New SqlCeReplication
    6.  
    7.             'Set the properties using data from the UI.
    8.             repl.Publisher = "dievechnology"
    9.             repl.PublisherLogin = "sa"
    10.             'repl.PublisherPassword = " "
    11.             repl.InternetUrl = "C:/Inetpub/wwwroot/Sean/sscesa20.dll"
    12.             'repl.InternetPassword = " "
    13.             repl.Subscriber = "Sean"
    14.             repl.Publication = "DIEVECHNOLOGY\Keen"
    15.             repl.PublisherDatabase = "Sean"
    16.             strDataSource = "\My Documents\Sean"
    17.             ssceConn.ConnectionString = "Data Source =" + strDataSource
    18.             repl.SubscriberConnectionString = "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=" + strDataSource
    19.  
    20.             'If the file does not exist, create it, and add it as a subscription.
    21.             While System.IO.File.Exists(strDataSource) = False
    22.  
    23.                 If MessageBox.Show("The file does not exist, do you want to create it?", _
    24.                    "Merge", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, _
    25.                    MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
    26.                     repl.AddSubscription(AddOption.CreateDatabase)
    27.                     Me.Refresh()
    28.                 End If
    29.             End While
    30.  
    31.             'Synchronize.
    32.             repl.Synchronize()
    33.  
    34.         Catch err As SqlCeException
    35.             'Add error handling code here.
    36.             MessageBox.Show(Err.Message)
    37.         Finally
    38.             repl.Dispose()
    39.  
    40.         End Try
    41.  
    42.     End Sub
    43.  
    44.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    45.         Dim repl As SqlCeReplication = Nothing
    46.  
    47.         Try
    48.             ' Set the Replication object.
    49.             repl = New SqlCeReplication
    50.             repl.InternetUrl = "C:/Inetpub/wwwroot/Sean/sscesa20.dll"
    51.             repl.InternetLogin = "MyLogin"
    52.             repl.InternetPassword = " "
    53.             repl.Publisher = "dievechnology"
    54.             repl.PublisherDatabase = "MyPublisher Database"
    55.             repl.PublisherLogin = " "
    56.             repl.PublisherPassword = "<MyPublisher Password>"
    57.             repl.Publication = "MyPublication"
    58.             repl.SubscriberConnectionString = "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\Sean.sdf"
    59.             repl.Subscriber = "MySubscriber"
    60.  
    61.             ' Mark the subscription for reinitialization with Upload first.
    62.             repl.ReinitializeSubscription(True)
    63.  
    64.             ' Synchronize to the instance of SQL Server 2000 to populate the Subscription.
    65.             repl.Synchronize()
    66.  
    67.         Catch ex As SqlCeException
    68.             ' Use your own error handling routine to show error information.
    69.             ' ShowErrors(e)
    70.             MessageBox.Show(ex.Message)
    71.  
    72.         Finally
    73.             ' Dispose of the Replication object.
    74.             repl.Dispose()
    75.         End Try

    hopefully u guys can help in this simple yet difficult problem for me. =)
    *wink wink*

    _babyekc

  14. #14

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: help in simple coding for pda =)

    anybody can help?
    *wink wink*

    _babyekc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width