Thursday, March 29, 2012
Correct syntax for Substring?
format below it works if the length is greater than 20 but gives an '#Error'
when less than 20. Is my syntax wrong?
=Iif(Fields!CustName.Value.ToString().Length() > 20,
Fields!CustName.Value.ToString().Substring(0,20), Fields!CustName.Value)
ThanksMike,
Instead of using the if statement, you could just use the Left()
function. This will return the left X characters of your string.
Try using =Left(Fields!CustName.Value, 20)
Regards,
Dan
Mike Harbinger wrote:
> I want to limit the length of a text box to 20 characters and using the
> format below it works if the length is greater than 20 but gives an '#Error'
> when less than 20. Is my syntax wrong?
> =Iif(Fields!CustName.Value.ToString().Length() > 20,
> Fields!CustName.Value.ToString().Substring(0,20), Fields!CustName.Value)
>
> Thanks|||Dan, as always, simple is best. I am still learning about functions so many
thanks !!
Chris
"Dan" <daniel.lenz@.qg.com> wrote in message
news:1145637948.118906.3030@.g10g2000cwb.googlegroups.com...
> Mike,
> Instead of using the if statement, you could just use the Left()
> function. This will return the left X characters of your string.
> Try using =Left(Fields!CustName.Value, 20)
> Regards,
> Dan
>
> Mike Harbinger wrote:
>> I want to limit the length of a text box to 20 characters and using the
>> format below it works if the length is greater than 20 but gives an
>> '#Error'
>> when less than 20. Is my syntax wrong?
>> =Iif(Fields!CustName.Value.ToString().Length() > 20,
>> Fields!CustName.Value.ToString().Substring(0,20), Fields!CustName.Value)
>>
>> Thanks
>sql
Tuesday, March 27, 2012
Correct format for set arithabort on
Dim MyCommand1 As New SqlCommand("addprospcus", MyConnection)
MyCommand1.CommandText = "set arithabort on"
MyCommand1.CommandType = CommandType.StoredProcedure
MyCommand1.Parameters.Add(New SqlParameter("@.Namecust", SqlDbType.NVarChar, 60))
MyCommand1.Parameters("@.namecust").Value = txtProspName.Text.ToString
MyCommand1.Parameters.Add(New SqlParameter("@.codeterr", SqlDbType.NVarChar, 6))
MyCommand1.Parameters("@.codeterr").Value = Trim(TerritoryList1.SelectedItem.Value.ToString)
MyConnection.Open()
MyCommand1.ExecuteNonQuery()
MyConnection.Close()
This is incorrect, but I can not find the correct syntax for calling my stored procedure but first setting "arithabort on".
Thanks in advance for your assistance.why wouldnt you set it inside the stored proc itself ?|||That does not work - I recieve the following error, "INSERT failed because the following SET options have incorrect settings: 'ARITHABORT'". There is alot of information about this and some of the advice states that the "set arithabort on" needs to be set before executing the stored procedure.
Currently I am getting around this error by using a nested sproc I call a sproc from my asp.net web form this stored procedure sets arithabort on and then executes a second sproc that actually does the insert.
the internal sproc runs correctly from Sql query analyser and when executed from another sproc as stated above, but not from my webform. Several articles have stated that the "set arithabort on" needs to be set from the application such as microsoft article ID: 305333
MyConnection.Execute "SET ARITHABORT ON"but I could not get this to work.|||when you create the stored proc
SET ARITHABORT ON
GO
ALTER PROCEDURE yourproc ...
-- your stored proc codeSET ARITHABORT OFF
GO
hth|||I trie this procedure but it does not help. I still get the error. The only way, so far, that I have been able to use my stored procedure from my web application is to use a nested Sproc.
I did based on your advice try to change my original sproc using the procedure in your post. I alter the sproc and it will execute and insert records from query analyzer but not from my application. But if I nest my sproc with the calling sproc being executed from my application and the calling sproc set arithabort on, executes my nested sproc, and then set arithabort off; my records are correctly inserted into my table.
Thursday, March 22, 2012
copying sql table to computer hard drive
Hi,
I use sql server management express. I have created a table on my hosts remote database and i want to copy the table (or the data) in some format or other to my hard drive. does anyone have any good ideas how i may do this either through management express or other means.
thanks a lot
nick
http://www.cryer.co.uk/brian/sqlserver/howtoexportcsv.htm
http://www.codeproject.com/aspnet/ImportExportCSV.asp
thanks mike, i shall give this a whirl
nick