Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:40:32+00:00 2026-05-23T13:40:32+00:00

Protected Sub cmdOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdOK.Click Dim medID,

  • 0
Protected Sub cmdOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdOK.Click
        Dim medID, medName, comment As String
        Dim power, period, qtty As Integer
        'Dim nextDateOfDelivery As Date = getNextDateOfDelivery(Val(txtDays.Text))
        Dim today As System.DateTime
        Dim answer As System.DateTime
        today = System.DateTime.Now
        answer = today.AddDays(Val(txtDays.Text))
        Dim nextDateOfDelivery As Date = answer


        medName = Trim(txtMedName.Text)
        qtty = Val(txtQuantity.Text)
        comment = txtComment.Text
        power = txtPower.Text
        medID = lblMedID.Text
        period = Val(txtDays.Text)
        '............setting priorities
        '.......value of p(0) indicates priority for tablest and so on so forth.....
        Dim p() As Integer = {0, 0, 0, 0}
        For i = 0 To LBPriorities.Items.Count - 1
            Select Case LBPriorities.Items(i).Text
                Case "Tablet"
                    p(0) = i + 1
                Case "Capsule"
                    p(1) = i + 1
                Case "Liquid"
                    p(2) = i + 1
                Case "Injection"
                    p(3) = i + 1

            End Select

        Next

        '............if not available
        Dim strictlyThis As String = radNotAvailable.SelectedItem.Value
        Dim connStr As String = ConfigurationManager.ConnectionStrings("databaseConnectionString").ConnectionString

        Dim con As New SqlClient.SqlConnection(connStr)
        'Dim con As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;" & _
        '                                       "AttachDbFilename=|DataDirectory|\database.mdf;" & _
        '                                       "Integrated Security=True;User Instance=True")

        Dim sql As New SqlClient.SqlCommand("INSERT INTO medicine" & _
            "(medID, userID, medName, quantity, dateOfOrder, power, tabPriority, capPriority, liqPriority, " & _
            "injPriority, period, notAvailable, prescription, comment, nextDateOfDelivery)" & _
            "VALUES('" & medID & "','" & User.Identity.Name & "','" & medName & "'," & qtty & ",'" & today & "'," & power & _
            "," & p(0) & "," & p(1) & "," & p(2) & "," & p(3) & ",'" & period & "','" & strictlyThis & "', '' ,'" & comment & "','" & nextDateOfDelivery & "')", con)

        con.Open()
        sql.ExecuteNonQuery()
        con.Close()
        con.Dispose()

        lblMessage.Text = "The details of the medicine have been saved. You may upload a prescription"
        FUPrescription.Enabled = True
        cmdUpload.Enabled = True
    End Sub

this is what i am using now…but i get an error saying “String or binary data would be truncated.
The statement has been terminated.” what does this mean???is there something wrong with my sql statement???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:40:32+00:00Added an answer on May 23, 2026 at 1:40 pm

    I’d say it was the value you’re storing in dateOfOrder.

    According to your screenshot, this is a VarChar(10), but you’re storing DateTime.Now.ToString() in there, the default value of which is of the format:

    5/1/2008 6:32:06 PM
    

    Which comes in at 19 characters.

    I suggest you store Dates and Times in a more suitable field, such as a Date or DateTime field.

    If you must store it as text, then you should at least store it in a format that is suitable for sorting, and unambiguous, such as:

    DateTime.Now.ToString("o") // Round-trip format
    

    Which will give you:

    2008-06-15T21:15:07.0000000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim ResourceObject
codebehind Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ds
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged Dim SQLData
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim lab
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SQLData
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SQLData
Protected Sub s1click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles s1.Click If s1.ImageUrl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Literal1.Text =
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged Dim rptv

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.