1 Replies - 3102 Views - Last Post: 21 September 2011 - 08:05 AM

#1 dougancil  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 29-June 10

Adding a day to a stored variable and saving that as a variable

Posted 12 September 2011 - 12:11 PM

I have the following code:

Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles wasoncallButton.Click
        Dim ds As New DataSet
        Dim dt As New DataTable
        Dim da As New SqlDataAdapter
        Dim cmd As New SqlCommand
        Dim myDate, newDate As DateTime
        Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
        Dim con As New SqlConnection(connectionString)
        con.Open()
        cmd.Connection = con
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "sp_owncalls3"
        cmd.Parameters.AddWithValue("@mydate", dateTextBox.Text)
  

        Try
            If DateTime.TryParse(dateTextBox.Text, myDate) Then
                'Conversion was successful, the data is now in myDate
                newDate = myDate.AddDays(1)
            Else
                errorlabel.Text = "Invalid Date"
            End If
        Catch ex As Exception
            Response.Write("Error:" & ex.ToString)
        End Try
    End Sub


End Class



and what I'm needing to do is to pass both the mydate variable and the newdate variable to my stored procedure. What is the best methodology for doing this? Do I just need to pass the value as a addwithvalues parameter?

Thank you

Doug

Is This A Good Question/Topic? 0
  • +

Replies To: Adding a day to a stored variable and saving that as a variable

#2 Frinavale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 203
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: Adding a day to a stored variable and saving that as a variable

Posted 21 September 2011 - 08:05 AM

I'm pretty sure the AddWithValue will work fine :)
Try it and find out!

-Frinny

This post has been edited by Frinavale: 21 September 2011 - 08:06 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1