Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
G

gengel

@gengel
About
Posts
16
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Whats wrong with SQL statement?
    G gengel

    Sorry found the problem. , before the FROM in the first bracket. It works perfectly. Thanks for the help.

    Database database question

  • Whats wrong with SQL statement?
    G gengel

    Wow. did not even know you could do this. I get this error though: Msg 156, Level 15, State 1, Line 8 Incorrect syntax near the keyword 'FROM'. Msg 102, Level 15, State 1, Line 19 Incorrect syntax near 'l'. I am going to break it down into components to make sure the parts work and then try and connect it back together again. Thanks

    Database database question

  • Whats wrong with SQL statement?
    G gengel

    Hi, Thanks for the replies. This query only seems to make a 1 to 1 join. So if there is only one log entry it returns both SHIPPED and PACKED as 1 instead of 1294. ProductionNo SHIPPED PACKED 10007627289 1 1 if i remove: WHERE (UNITS.ScanStatus = 'SHIPPED') AND (UNIT_Logs.Old_Status = 'PACKED') ProductionNo SHIPPED PACKED 10007627289 1294 1294 I tried this mess. Will try a few more options with this. SELECT UNITS.ProductionNo, COUNT(UNITS.SerialNo) AS SHIPPED FROM UNITS WHERE UNITS.Scanstatus='SHIPPED' AND (SELECT COUNT(UNIT_Logs.SerialNo) AS PACKED FROM UNIT_Logs WHERE UNIT_Logs.Old_Status='PACKED') GROUP BY UNITS.ProductionNo

    Database database question

  • Whats wrong with SQL statement?
    G gengel

    Table 1 (UNITS) ScanID ScanCount OrderID SerialNo ScanStatus ProductionNo 1981 1294 2 147639NZ301774 SHIPPED 10007627289 There are 1300 SerialNo's for ProductionNo That will end with status 'SHIPPED' Table 2 (Unit_Logs) LogID SerialNo ProductionNo Old_Status New_Status 1 147639NZ301774 10007627289 PACKED SHIPPED There will be 1300 records with status changes from PACKED to SHIPPED Needed RESULT: ProductionNo PACKED SHIPPED 10007627289 1300 1300 This is what I have tried: SELECT UNITS.ProductionNo, COUNT(UNITS.SerialNo) AS SHIPPED, COUNT(UNIT_Logs.SerialNo) AS PACKED FROM UNITS JOIN UNIT_Logs ON UNITS.ProductionNo = UNIT_Logs.ProductionNo GROUP BY UNITS.ProductionNo, UNITS.ScanStatus, UNIT_Logs.Old_Status HAVING (UNITS.ScanStatus = 'SHIPPED') AND (UNIT_Logs.Old_Status = 'PACKED') I added 1 log entry to the table, but the query returns nothing. Think might need sub query, but not sure where to go from here.

    Database database question

  • How do you consume an existing web serivce
    G gengel

    Thanks. Just what I needed.

    Visual Basic csharp help tutorial question

  • How do you consume an existing web serivce
    G gengel

    Good day, I have created a webservice in visual web developer express. "http://localhost:50198/ScanShip.asmx" It has a function: "http://localhost:50198/ScanShip.asmx?op=CheckSerial" How would I now consume this webservice from Visual Basic .net. You cannot create a webservice in visual basic 2008 express and all the documentation explains how to set up the webserivce and then consume it in the same project. I only want vb.net to consume an existing web service. Any help would be appreciated.

    Visual Basic csharp help tutorial question

  • VB Webservice for WinCE project
    G gengel

    Good day, Not sure if should rather be under ASP or embedded, but I am doing the development in vb.net. I can't quite figure out how to proceed with this problem. just need someone to point me in the right direction. I have a VB (VB 2008 Express) windows form app that connects up to a SQL express DB . Everything works fine there. I created a datalayer class and a business layer class. The datalayer handels all database connection functions and the business layer handles search functions that returns datarows and several other lookup and update functions. Now I want a Windows CE symbol bar code scanner (vb.net 2003 compact framework 1. Framework 2 to big for device memory) to connect up to the vb app. Eg.: I have a function in the business layer class that checks for duplicate numbers scanned. I want the CD device to scan the number and then feed it to the function in the business layer. But I think it might not work if I create the business object on the device. I need business class to reside on the server. ASP? Web service? As I say not sure where to go from here. It also seems that VB .net Express cannot create web services and ASP websites. you need Visual Web developer 2008 express edition for that. Not sure how to link the two. I would appreciate any advice. Thanks

    Visual Basic database csharp wcf sysadmin

  • vb.net 2008 Express to SQL - Dataset does not show changes in DB
    G gengel

    I think I found the problem. Not sure why this makes a difference? da.FillSchema(pDS, SchemaType.Source, TableName)

    Visual Basic database csharp tutorial announcement

  • Different ADO.net Db Update Methods-What is better?
    G gengel

    Good day, What is the difference between these methods of updating and which is better: 1. Add new row to datatable Dim dr As DataRow = dt.NewRow dr.Item("OrderStatus") = "OPEN" dt.Rows.Add(dr) 'Update new row to database Dim qry As String = "SELECT * FROM Table" Conn.Open() Dim da1 As New SqlClient.SqlDataAdapter da1.SelectCommand = New SqlClient.SqlCommand(qry, MAIN.data.Conn) Dim cb1 As SqlClient.SqlCommandBuilder = New System.Data.SqlClient.SqlCommandBuilder(da1) da1.Update(MAIN.data.DS, "Table") conn.close 2. Execute non query - does this work as stored procedure? Dim strSQL As String = "INSERT INTO Table (OrderStatus)VALUES (@OrderStatus) Dim cmdAddNew As New SqlClient.SqlCommand(strSQL, Conn) cmdAddNew.Parameters.Add("@ScanStatus", SqlDbType.Varchar,50).Value = "OPEN" Conn.Open() cmdAddNew.ExecuteNonQuery() Conn.Close()

    Visual Basic database question csharp announcement

  • vb.net 2008 Express to SQL - Dataset does not show changes in DB
    G gengel

    Sorry this should just be Load_Table 'Reatach datatable to dataset. Refresh primary keys MAIN.data.Load_Table("SELECT * FROM Orders", "Orders")

    Visual Basic database csharp tutorial announcement

  • vb.net 2008 Express to SQL - Dataset does not show changes in DB
    G gengel

    Hi, I am a little confused now. the code that I am using is based on several references and websites. I thought that was the idea of ADO.net. Work with data offline. What is the corrct way of doing this. I have tried to simplify my code below.

    Imports System
    Imports System.Data
    Imports System.Data.SqlClient

    Public Class Example
    Dim SQLcon As New SqlConnection
    Dim pDS As New DataSet

    Sub MakeConnect()
        SQLcon.ConnectionString = "Data Source=192.168.10.24\\BDMS;" & \_
                                        "Initial Catalog=FLATPAN;" & \_
                                        "User ID=flatpan;" & \_
                                        "Password=\*\*\*\*\*\*\*\*\*"
        Try
            SQLcon.Open()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    
    End Sub
    
    Sub Load\_Table()
        Dim SQLstr As String = "SELECT \* FROM Orders"
        Try
            'open connection
            If SQLcon.State = ConnectionState.Closed Then
                SQLcon.Open()
            End If
            Dim cmd As SqlCommand = New SqlCommand(SQLstr, SQLcon)
            Dim da As New SqlDataAdapter(SQLstr, SQLcon)
            da.Fill(pDS, "ORDERS")
            
            'Added this to see if it helped
            da.FillSchema(pDS, SchemaType.Mapped)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            'close connection
            SQLcon.Close()
        End Try
    End Sub
    
    Sub Add\_New\_Record()
        Try
            Dim dt As DataTable = pDS.Tables("Orders")
            Dim dr As DataRow = dt.NewRow
            dr.Item("OrderStatus") = "A"
            dr.Item("SamsungRef") = "B"
            dr.Item("ProductCode") = "C"
            dr.Item("ProductSerialNo") = "D"
            dr.Item("ProductionNo") = "E"
            dt.Rows.Add(dr)
    
            'Update new row to database
            Dim qry As String = "SELECT \* FROM Orders"
            If SQLcon.State = ConnectionState.Closed Then SQLcon.Open()
            Dim da1 As New SqlClient.SqlDataAdapter
            da1.SelectCommand = New SqlClient.SqlCommand(qry, MAIN.data.Conn)
            Dim cb1 As SqlClient.SqlCommandBuilder = New System.Data.SqlClient.SqlCommandBuilder(da1)
            da1.Update(pDS, "Orders")
    
            'Had to add this to register change in dataset
            pDS.Tables.Remove("Orders")
            'Reatach datatable to dataset. Refresh primary keys
    
    Visual Basic database csharp tutorial announcement

  • vb.net 2008 Express to SQL - Dataset does not show changes in DB
    G gengel

    Hi, Hope this helps. Datalayer class

    Dim pDS As New DataSet

    Public Property DS() As DataSet
        Get
            Return pDS
        End Get
        Set(ByVal value As DataSet)
            pDS = value
        End Set
    End Property
    

    Sub MakeConnect()
    SQLcon.ConnectionString = "Data Source=192.168.10.24\BDMS;" & _
    "Initial Catalog=FLATPAN;" & _
    "User ID=flatpan;" & _
    "Password=*******"
    Try
    SQLcon.Open()
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    End Try

    End Sub
    

    Function Load_Table(ByVal SQLString As String, ByVal TableName As String) As Boolean

        Dim SQLstr As String
        Dim tableISadded As Boolean = False
        Try
            'open connection
            If SQLcon.State = ConnectionState.Closed Then
                SQLcon.Open()
            End If
            SQLstr = SQLString
            Dim cmd As SqlCommand = New SqlCommand(SQLstr, SQLcon)
            Dim da As New SqlDataAdapter(SQLstr, SQLcon)
            da.Fill(pDS, TableName)
            da.FillSchema(pDS, SchemaType.Mapped)
            For Each dt As DataTable In pDS.Tables
                If dt.TableName = TableName Then
                    tableISadded = True
                Else
                    tableISadded = False
                End If
            Next
            Return tableISadded
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Return False
        Finally
            'close connection
            SQLcon.Close()
        End Try
    

    On the orders form call the Load_Table function to add the table to the dataset. This works.

    Private Sub Orders_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Load the orders table and lu products table
    MAIN.data.Load_Table("SELECT * FROM Orders", "Orders") 'THIS IS THE DA FILL FOR ORDERS
    MAIN.data.Load_Table("SELECT * FROM LU_Products", "LU_Products")
    MAIN.data.Load_Table("SELECT * FROM Status_Orders", "Status_Orders")
    Calculate_Total_Rows(0, "LOAD") 'SOME FORM ACTIONS
    Fields_Load(rowCounter) 'NOT PART OF UPDATE ONLY TO VIEW DATA
    Fields_State("LOCK") 'LOCK FIELDS SO USER CANT CHANGE
    End Sub

    Here add a new row to the ORDERS table. This works, but cannot see th

    Visual Basic database csharp tutorial announcement

  • vb.net 2008 Express to SQL - Dataset does not show changes in DB
    G gengel

    Hi, Thanks for your reply. I only added the accept changes later when I noticed that the ADO.net dataset-datatable is not updating. The SQL database contains the new data that was added, but the change is not reflected back to the Dataset-datatable. This is what I am doing now to update the data set

    Function Load_Table(ByVal SQLString As String, ByVal TableName As String) As Boolean

        Dim SQLstr As String
        Dim tableISadded As Boolean = False
        Try
            'open connection
            If SQLcon.State = ConnectionState.Closed Then
                SQLcon.Open()
            End If
            SQLstr = SQLString
            Dim cmd As SqlCommand = New SqlCommand(SQLstr, SQLcon)
            Dim da As New SqlDataAdapter(SQLstr, SQLcon)
            da.Fill(pDS, TableName)
            da.FillSchema(pDS, SchemaType.Mapped)
            For Each dt As DataTable In pDS.Tables
                If dt.TableName = TableName Then
                    tableISadded = True
                Else
                    tableISadded = False
                End If
            Next
            Return tableISadded
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Return False
        Finally
            'close connection
            SQLcon.Close()
        End Try
    
    End Function
    
               'Remove the orders table
                MAIN.data.DS.Tables.Remove("Orders")
                ''Reload datatable to dataset. 
                MAIN.data.Load\_Table("SELECT \* FROM Orders", "Orders")
    
    Visual Basic database csharp tutorial announcement

  • vb.net 2008 Express to SQL - Dataset does not show changes in DB
    G gengel

    Good day, I have tried various methods to update an SQL database, but every time the database is updated but not the dataset. I have done it with addrow and accept changes and with execute no query, but the dataset does not register the changes made. I have to MAIN.data.DS.Tables.Remove("Orders") and then add the datatable back to the dataset with the data adapter: Example 1:

    Function Add_Orders_Row() As Boolean
    Try
    Dim RowISAdded As Boolean = False
    If txtQuantity.Text <> "" And txtProductionNo.Text <> "" _
    And txtWeek.Text <> "" And txtPart.Text <> "" _
    And cboProductCode.Text <> "" And txtPart.Text <> "" _
    And txtWorksOrderNo.Text <> "" Then
    Dim dt As DataTable = MAIN.data.DS.Tables("Orders")
    Dim dr As DataRow = dt.NewRow
    dr.Item("OrderStatus") = cboOrderStatus.Text
    dr.Item("SamsungRef") = "NA"
    dr.Item("ProductCode") = cboProductCode.Text
    dr.Item("ProductSerialNo") = txtProductSerialNo.Text
    dr.Item("ProductionNo") = txtProductionNo.Text
    dr.Item("WeekNo") = txtWeek.Text
    dr.Item("PartNo") = CType(txtPart.Text, Integer)
    dr.Item("OrderDate") = dtpOrderDate.Text
    dr.Item("QuantityOrder") = CType(txtQuantity.Text, Integer)
    dr.Item("QuantityScanned") = 0
    dr.Item("WorksOrderNo") = txtWorksOrderNo.Text
    If txtFirstSerial.Text = "" Then
    dr.Item("FirstSerialNo") = "<SCAN>"
    dr.Item("LastSerialNo") = "<CALC>"
    Else
    dr.Item("FirstSerialNo") = txtFirstSerial.Text
    dr.Item("LastSerialNo") = txtLastSerial.Text
    End If

                dr.Item("timenow") = Date.Now
                dt.Rows.Add(dr)
                'Update new row to database
                Dim qry As String = "SELECT \* FROM Orders"
                If MAIN.data.Conn.State = ConnectionState.Closed Then MAIN.data.Conn.Open()
                Dim da1 As New SqlClient.SqlDataAdapter
                da1.SelectCommand = New SqlClient.SqlCommand(qry, MAIN.data.Conn)
                Dim cb1 As SqlClient.SqlCommandBuilder = New System.Data.SqlClient.SqlCommandBuilder(da1)
                da1.Update(MAIN.data.
    
    Visual Basic database csharp tutorial announcement

  • Timer that will fire at 100-400kHz
    G gengel

    My math was wrong above. its 10 to 2.5 microseconds.

    Visual Basic csharp css help tutorial

  • Timer that will fire at 100-400kHz
    G gengel

    Good Day, I am busy writing a I2C communication link through the printer port. I need to set up a square wave of 100-400kHz for the I2C clock signal. This is for an EEPROM programmer. I was going to use the windows timer, but the interval only goes down to 1 ms. I need an interval less than 10 to 2.5 nano second. I was trying to use system.timers.timer, but am not sure if this is the correct class for what I need to do. Is there another way to create and interval or a delay in vb.net? Is there an example implementation for sytem.timers.timer? Here is my code for system.timers.timer: Public Class Main Dim WithEvents myTimer As New System.Timers.Timer Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load myTimer_Init() AddHandler myTimer.Elapsed, AddressOf myTimer_Run End Sub Sub myTimer_Init() With myTimer .Interval = 0.001 .Enabled = True End With End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click myTimer.Start() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click myTimer.Stop() End Sub Dim counter As Long Sub myTimer_Run() counter += 1 TextBox1.Text = counter.ToString End Sub End Class Error at runtime: Cross-thread operation not valid: Control 'TextBox1' accessed from a thread other than the thread it was created on.

    Visual Basic csharp css help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups