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
  1. Home
  2. Web Development
  3. ASP.NET
  4. read file name problem

read file name problem

Scheduled Pinned Locked Moved ASP.NET
helpdesigndata-structuresdebuggingannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LovelyHelp
    wrote on last edited by
    #1

    :sigh:I trying to update my t_linkTitle with the file name that ihave upload to webserver (sFile1. sFile12, sFile13). My code is as below. But when i run my code, there is a incorrect syntax as below Syntax Error: --------------------------------------------------------------------------------- Line 1: Incorrect syntax near ','. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ','. Source Error: Line 601: ' Try Line 602: myconnection.Open() Line 603: mycommand.ExecuteNonQuery() Line 604: ' lblDelMsg.Text = "File Update successfully" Line 605: ' Catch Exp As SqlException Source File: c:\inetpub\wwwroot\fyp\Admin\addCourseMaterial.aspx.vb Line: 603 Stack Trace: [SqlException (0x80131904): Line 1: Incorrect syntax near ','.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857354 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734966 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 addCourseMaterial.bttnUpUpdate_ServerClick(Object sender, EventArgs e) in c:\inetpub\wwwroot\fyp\Admin\addCourseMaterial.aspx.vb:603 System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e) +105 System.Web.UI.HtmlControls.HtmlInputButton.RaisePostBackEvent(String eventArgument) +106 System.Web.UI.HtmlControls.HtmlInputButton.System.

    A 1 Reply Last reply
    0
    • L LovelyHelp

      :sigh:I trying to update my t_linkTitle with the file name that ihave upload to webserver (sFile1. sFile12, sFile13). My code is as below. But when i run my code, there is a incorrect syntax as below Syntax Error: --------------------------------------------------------------------------------- Line 1: Incorrect syntax near ','. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ','. Source Error: Line 601: ' Try Line 602: myconnection.Open() Line 603: mycommand.ExecuteNonQuery() Line 604: ' lblDelMsg.Text = "File Update successfully" Line 605: ' Catch Exp As SqlException Source File: c:\inetpub\wwwroot\fyp\Admin\addCourseMaterial.aspx.vb Line: 603 Stack Trace: [SqlException (0x80131904): Line 1: Incorrect syntax near ','.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857354 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734966 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 addCourseMaterial.bttnUpUpdate_ServerClick(Object sender, EventArgs e) in c:\inetpub\wwwroot\fyp\Admin\addCourseMaterial.aspx.vb:603 System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e) +105 System.Web.UI.HtmlControls.HtmlInputButton.RaisePostBackEvent(String eventArgument) +106 System.Web.UI.HtmlControls.HtmlInputButton.System.

      A Offline
      A Offline
      albCode
      wrote on last edited by
      #2

      after u declared SqlCommand u leave it without parameters assign it via properties as this: mycommand = New SqlCommand() mycommand.Connection = myconnection mycommand.CommandText = "Update t_linkTitle SET link_title=@txtUpTitle, link_url=@txtUpLink,link_file1=@File11, link_file2@File21, link_file3@File31 WHERE link_titleid= '" + selectedID + "'" and continue ur code the error Line 1: Incorrect syntax near ','. comes cause of this part of code WHERE link_titleid=" + selectedID, myconnection) because selectdID is string and u must include SQL qoute _____________________ Proud to be Albanian _____________________

      L 1 Reply Last reply
      0
      • A albCode

        after u declared SqlCommand u leave it without parameters assign it via properties as this: mycommand = New SqlCommand() mycommand.Connection = myconnection mycommand.CommandText = "Update t_linkTitle SET link_title=@txtUpTitle, link_url=@txtUpLink,link_file1=@File11, link_file2@File21, link_file3@File31 WHERE link_titleid= '" + selectedID + "'" and continue ur code the error Line 1: Incorrect syntax near ','. comes cause of this part of code WHERE link_titleid=" + selectedID, myconnection) because selectdID is string and u must include SQL qoute _____________________ Proud to be Albanian _____________________

        L Offline
        L Offline
        LovelyHelp
        wrote on last edited by
        #3

        :confused:I still facing the problem after replace my code with your code..maybe i should paste all my code here. It is a bit of complicated. Protected Sub bttnUpUpdate_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles bttnUpUpdate.ServerClick 'set the panel of selection function to display Dim sPath1 As String Dim sFile1 As String = "" Dim sFullPath1 As String Dim sSplit1() As String Dim sPathFriendly1 As String Dim sFile12 As String = "" Dim sFullPath12 As String Dim sSplit12() As String Dim sFile13 As String = "" Dim sFullPath13 As String Dim sSplit13() As String 'Upload to same path as script 'Internet Anonymous User must have write permissions sPath1 = Server.MapPath("../tutorial") If Right(sPath1, 1) <> "\" Then sPathFriendly1 = sPath1 'Friendly path name for display sPath1 = sPath1 & "\" ' Response.Write("Path Friendly: " & sPathFriendly) Else sPathFriendly1 = Left(sPath1, Len(sPath1) - 1) End If 'Save as same file name being posted 'The code below resolves the file name '(removes path info) If FileUpUpload.PostedFile.FileName <> "" Then sFile1 = FileUpUpload.PostedFile.FileName sSplit1 = Split(sFile1, "\") sFile1 = sSplit1(UBound(sSplit1)) sFullPath1 = sPath1 & sFile1 Try FileUpUpload.PostedFile.SaveAs(sFullPath1) ' Response.Write("
        FInally: " & sFullPath) lblResults.Text = "
        Upload of File to " & sPathFriendly1 & " succeeded" Catch Ex As Exception lblResults.Text = "
        Upload of File to " & sPathFriendly1 & " failed for the following reason: " & Ex.Message Finally lblResults.Font.Bold = True lblResults.Visible = True End Try End If If FileUpUpload2.PostedFile.FileName <> "" Then sFile12 = FileUpUpload2.PostedFile.FileName sSplit12 = Split(sFile12, "\") sFile12 = sSplit12(UBound(sSplit12)) sFullPath12 = sPath1 & sFile12 Try FileUpUpload2.PostedFile.SaveAs(sFullPath12) ' Response.Write("
        FInally2: " & sFullPath2) lblResults.Text = "
        Upload of File to " & sPathF

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

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