locked
Dataset for client? RRS feed

  • Question

  •  

    Hey fellow snyc dudes and dudettes... :) Anyone had any trouble using a dataset for return values in a datagridview for the client app?

    trying to make this work...

    ' Open the Connection For SQL Compact Edition

    Dim cn As New SqlServerCe.SqlCeConnection("Data Source = " & Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\ffgsCRM.sdf")

    Dim cmdProduct As SqlServerCe.SqlCeCommand

    ' create dataset with table

    cn.Open()

    cmdProduct = cn.CreateCommand

    cmdProduct.CommandText = "SELECT ProductDesc AS Description, ProductCost AS Cost, ProductListPrice AS [List Price] FROM Product"

    Dim daProduct As New SqlServerCe.SqlCeDataAdapter(cmdProduct)

    Dim dtProduct As New Data.DataTable("Product")

    daProduct.Fill(dtProduct)

    Dim ds As New DataSet

    ds.Tables.Add(dtProduct)

    '' FILL DATAGRIDVIEW

    Me.dbGridProducts.DataSource = ds

     

    I have this working:

    ' search product description

    Dim reqProductSearch As String

    reqProductSearch = tstxtSearchDescription.Text

    ' Open the Connection For SQL Compact Edition

    Dim _conn = New SqlCeConnection("Data Source = " & Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\ffgsCRM.sdf")

    Dim cmd As New SqlCeCommand()

    cmd.Connection = _conn

    cmd.CommandText = "select ProductDesc as Description, ProductCost as Cost, ProductListPrice as [List Price] from Product where ProductDesc like '%" & reqProductSearch & "%' ORDER BY ProductDesc"

    _conn.Open()

    Dim resultSet As SqlCeResultSet

    resultSet = cmd.ExecuteResultSet(ResultSetOptions.Scrollable Or ResultSetOptions.Updatable)

    '' FILL DATAGRIDVIEW

    dbGridProducts.DataSource = resultSet

    With dbGridProducts

    .Columns("Description").Width = 550

    End With

     

    Thanks,

    Bill

    • Moved by Max Wang_1983 Friday, April 22, 2011 11:14 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, March 2, 2007 8:41 PM

Answers

  •  

    got my brain back... DataTable and Dataset DataGridView examples...  :)

     

    'To Open the Connection To Connect to SQLCE 

    Dim ConsqlCombo As New SqlCeConnection

    ConsqlCombo.ConnectionString = "Data Source = " & Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\ffgsCRM.sdf"

    'SQL STATEMENT......

    Dim reqSQLCombo As New SqlCeCommand

    reqSQLCombo.CommandText = "select ProductDesc as Description, ProductCost as Cost, ProductListPrice as [List Price] from Product where ProductMfgID = '" & reqSearch & "'"

    reqSQLCombo.CommandType = CommandType.Text

    reqSQLCombo.Connection = ConsqlCombo

    'CREATE NEW SQL DATA ADAPTER

    Dim sqldaCombo As New SqlCeDataAdapter(reqSQLCombo)

    Dim sqldsCombo As New DataSet

    ' FILL DATASET

    sqldaCombo.Fill(sqldsCombo, "ProductDesc")

    '' FILL DATAGRID

    dbGridProducts.DataSource = sqldsCombo.Tables("ProductDesc")

    dbGridProducts.DataMember = "ProductDesc"

    Monday, March 5, 2007 7:19 AM