Mid Function in SQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ahmed Yasser
    New Member
    • Feb 2007
    • 12

    Mid Function in SQL

    Hi Everybody,
    i have a "create new project wizard" in my program, which allows the users to create a new project in just three steps. My problem is, to make it simple for the user, the program should determine a new project short name in case the user didn't enter one. To do so, i go to the Projects Table and Filters for the projects that have a short name like "PROJ - *" where the * is a serial number (i.e. PROJ - 99, PROJ - 105), gets their maximum and Adds 1 to it to get the new PROJ short name.

    I started by the following Query but i have an error in the Mid function.

    OleDbDataAdapte r3.SelectComman d.CommandText = "SELECT Mid(PROJSHORT,6 ,6) AS Pval FROM PROJECT WHERE (PROJECT.PROJSH ORT Like '%PROJ-%')"
    DsProj1.Clear()
    OleDbDataAdapte r3.Fill(DsProj1 , "ProjVal")
    PA = DsProj1.Tables( "ProjVal").Rows (0).Item("PVal" )


    Any Help Please
  • cbbibleboy
    New Member
    • Apr 2007
    • 29

    #2
    There is no "mid()" function in SQL, what you want is "SUBSTRING( )".

    Here's a helpful link: http://www.1keydata.com/sql/sql-substring.html
    Last edited by Killer42; Apr 29 '07, 11:52 AM. Reason: Activate link

    Comment

    Working...