By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Mid Function in SQL

P: 12
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.

OleDbDataAdapter3.SelectCommand.CommandText = "SELECT Mid(PROJSHORT,6,6) AS Pval FROM PROJECT WHERE (PROJECT.PROJSHORT Like '%PROJ-%')"
DsProj1.Clear()
OleDbDataAdapter3.Fill(DsProj1, "ProjVal")
PA = DsProj1.Tables("ProjVal").Rows(0).Item("PVal")


Any Help Please
Apr 28 '07 #1
Share this Question
Share on Google+
1 Reply


P: 29
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
Apr 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.