pls i need someone here to help me with the coding trend am using. this is an example of my code inserting data in to sql server 2008 table...

 Public Sub insertStocks(ByVal serialNumber As TextBox, ByVal itemcategory As ComboBox, ByVal itemname As TextBox, _
                        ByVal dateofmanufacture As DateTimePicker, ByVal dateofexpiry As DateTimePicker, _
                                ByVal price As TextBox, ByVal Clerkname As TextBox, _
                                ByVal Quantity As TextBox, ByVal measurement As ComboBox, _
                                ByVal Country As ComboBox, ByVal EntryDate As DateTimePicker, ByVal datag As DataGridView)
    Try
        If checkStocks(serialNumber, itemcategory, itemname, dateofmanufacture, dateofexpiry, price, Clerkname, Quantity, measurement, Country, EntryDate) = True Then
            Dim sql As String = "INSERT INTO Registration (serialNumber, itemcategory, itemname, dateofmanufacture," & _
            "dateofexpiry, price, Clerkname, Quantity, measurement, Country, EntryDate )  " & _
            "VALUES ('" & serialNumber.Text & "','" & itemcategory.Text & "','" & itemname.Text & "','" & dateofmanufacture.Text & "','" & dateofexpiry.Text & "'," & _
            "'" & price.Text & "','" & Clerkname.Text & "','" & Quantity.Text & "','" & measurement.Text & "'," & _
            "'" & Country.Text & "','" & EntryDate.Text & "')"
            serverconnection()
            Dim odbcCmd As New SqlCommand(sql, sqlcon)
            odbcCmd.ExecuteNonQuery()
            MsgBox("New Details About [" & itemname.Text & " with Serial Number " & serialNumber.Text & " ] saved ", MsgBoxStyle.Information)
            clearStocks(serialNumber, itemcategory, itemname, dateofmanufacture, dateofexpiry, price, Quantity, measurement, Country, EntryDate)
            serialNumber.Focus()
            loadpurchasesummary(datag)
            sqlcon.Close()
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

What is your question? Does your code work? If not, are you getting an error? If so then what is the error and what line is causing it? If you are just asking for suggestions then I suggest you use parameterized queries. You can find an example here in the code snippets section.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.