none
como guardar fecha de un control calendar en un campo de acces con asp.net en visual basic RRS feed

  • Pregunta

  • Hola a todos, despues de seleccionar una fecha en un calendar lo paso a un textbox, aqui pongo la =instruccion, El campo en la base de datos es tipo texto.

       txtstartdate.Text = Calendar1.SelectedDate.ToShortDateString

    al momento de que le doy guardarme tira este error.

    syntax error (missing operator) in query expression 'txtstartdate.Text.Tostring &'

    Aqui pongo el codigo:

    Imports System.Data.OleDb
    Imports System.Data

    Public Class Account
        Inherits System.Web.UI.Page
        Dim conConexion As OleDb.OleDbConnection
        Dim cmdComand As OleDb.OleDbCommand

        Protected Sub btnenviaraccountnew_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnenviaraccountnew.Click
            Try
                Dim con As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\luis.valdez\Documents\info.accdb"
                conConexion = New OleDb.OleDbConnection(con)
            Catch ex As Exception
                MsgBox("Error al conectarse")
            End Try

            'Guardar en la Base de datos
            Try
                conConexion.Open()
                cmdComand = New OleDb.OleDbCommand
                cmdComand.Connection = conConexion
            Catch ex As Exception
                MsgBox(ex.Message)
                MsgBox("Error de Conexion", MsgBoxStyle.Information, "Sistema")
            End Try

            Try
              

      'Hacemos una consulta Insert paras añadir un registro a la BD
                cmdComand = New OleDbCommand("INSERT INTO Accounts_Form (SSO_Account,FirstName_Account,MidlleName_Account," & vbCrLf &
    "Lastname1_Account,Lastname2_Account,StarDate_Account,TypeEmplye_Account,Function_Account,NewEmployestitle_Account," & vbCrLf &
    "PC_Account_Account,Email_Account,SupporCentral,oracle,oraclerespons1_Account,oraclerespons2_Account,oraclerespons3_Account,oraclerespons4_Account," & vbCrLf &
    "oraclerespons5_Account,oraclerespons6_Account,Discoverer_Account,Businessobjects,Tress_Account,Tress_respons1_Account,Telephone_Account," & vbCrLf &
    "Telphone_respons_Account,MMS_Account,Copierscan_Account,MicrosoftLync_Account,Otra_Account) VALUES( txtsso,txtfirstname, txtmidname," & vbCrLf &
    "txtlastname,txtlastname2,txtstartdate.Text.ToString &,Dropempletype.SelectedItem,Dropfunction.SelectedItem,txtemplotitle,CheckPC.Checked" & vbCrLf &
    "CheckEmail.Checked,Checksupcent.Checked,Checkoracle.Checked,Droprespon1.SelectedItem,Droprespon2.SelectedItem,Droprespon3.SelectedItem," & vbCrLf &
    "Droprespon4.SelectedItem,Droprespon5.SelectedItem,Droprespon6.SelectedItem,Checkdisc.Checked,Checkbussobj.Checked,Checktress.Checked &," & vbCrLf &
    "Droptress.SelectedItem,Checktelephone.Checked,Droptelephone.SelectedItem,CheckMMS.Checked,Checkcopscan.Checked,Checklync.Checked,Checkotra.Checked)", conConexion)

                'Agregamos aqui los valores a los parametros
                cmdComand.Parameters.AddWithValue("@SSO_Account", txtsso.Text)
                cmdComand.Parameters.AddWithValue("@FirstName_Account", txtfirstname.Text)
                cmdComand.Parameters.AddWithValue("@MidlleName_Account", txtmidname.Text)
                cmdComand.Parameters.AddWithValue("@Lastname1_Account", txtlastname.Text)
                cmdComand.Parameters.AddWithValue("@Lastname2_Account", txtlastname2.Text)
                cmdComand.Parameters.AddWithValue("@StarDate_Account", txtstartdate.Text)
                cmdComand.Parameters.AddWithValue("@TypeEmplye_Account", Dropempletype.Text)
                cmdComand.Parameters.AddWithValue("@Function_Account", Dropfunction.Text)
                cmdComand.Parameters.AddWithValue("@NewEmployestitle_Account", txtemplotitle.Text)
                cmdComand.Parameters.AddWithValue("@PC_Account_Account", CheckPC.Checked)
                cmdComand.Parameters.AddWithValue("@Email_Account", CheckEmail.Checked)
                cmdComand.Parameters.AddWithValue("@SupporCentral", Checksupcent.Text)
                cmdComand.Parameters.AddWithValue("@oracle", Checkoracle.Text)
                cmdComand.Parameters.AddWithValue("@oraclerespons1_Account", Droprespon1.SelectedItem.Text)
                cmdComand.Parameters.AddWithValue("@oraclerespons2_Account", Droprespon2.SelectedItem.Text)
                cmdComand.Parameters.AddWithValue("@oraclerespons3_Account", Droprespon3.SelectedItem.Text)
                cmdComand.Parameters.AddWithValue("@oraclerespons4_Account", Droprespon4.SelectedItem.Text)
                cmdComand.Parameters.AddWithValue("@oraclerespons5_Account", Droprespon5.SelectedItem.Text)
                cmdComand.Parameters.AddWithValue("@oraclerespons6_Account", Droprespon6.SelectedItem.Text)
                cmdComand.Parameters.AddWithValue("@Discoverer_Account", Checkdisc.Checked)
                cmdComand.Parameters.AddWithValue("@Businessobjects", Checkbussobj.Checked)
                cmdComand.Parameters.AddWithValue("@Tress_Account", Checktress.Checked)
                cmdComand.Parameters.AddWithValue("@Tress_respons1_Account", txtsso.Text)
                cmdComand.Parameters.AddWithValue("@Telephone_Account", Checktelephone.Checked)
                cmdComand.Parameters.AddWithValue("@Telphone_respons_Account", Droptelephone.SelectedItem.Text)
                cmdComand.Parameters.AddWithValue("@MMS_Account", CheckMMS.Checked)
                cmdComand.Parameters.AddWithValue("@MicrosoftLync_Account", Checklync.Checked)
                cmdComand.Parameters.AddWithValue("@Otra_Account", Checkotra.Checked)

                cmdComand.ExecuteNonQuery()

            Catch ex As Exception
                MsgBox(ex.Message)
                MsgBox("Error al Guardar", MsgBoxStyle.Information, "Sistema")
            End Try
        End Sub

        Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Calendar1.SelectionChanged
            txtstartdate.Text = Calendar1.SelectedDate.ToShortDateString
        End Sub

    martes, 5 de mayo de 2015 22:23

Respuestas