Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2007-04-26 : 15:38:50
|
| Hi, every body,I need your help. My stored procedure did not make it through. It did not get any error/exception, but the data did not get inserted. I have the permission checked to allow exec on the sp. And I can run the sp from my sql QA successfully.The connection string and other settings have been used on other similar calls without problem.Please help! And here are the pieces.1) UI (win form app in vs2005 vb.net), the param values are set correctly under break point.Private Sub UpdateNote(ByVal MailtoEmail As String) Dim arParms() As SqlParameter = New SqlParameter(1) {} Try arParms(0) = New SqlParameter("@P1", SqlDbType.VarChar, ParameterDirection.Input) arParms(0).Value = JobID arParms(1) = New SqlParameter("@P2", SqlDbType.VarChar, ParameterDirection.Input) arParms(1).Value = MailtoEmail SqlHelper.ExecuteNonQuery(cn_str_QWPro, CommandType.StoredProcedure, _ "CT_setIntNote", arParms) Catch Ex As Exception Console.WriteLine(Ex.Message) End Try End Sub2) data access, i.e. SqlHelper.ExecuteNonQuery is from ms application block data access lib3) sp (the field I try to update is of data type TEXT in sql2k, and I have tried two different type sp, one using straight UPDATE, another is for WRTETEXT, but neither works)3)-1 UPDATE versionCREATE PROCEDURE [dbo].[CT_setIntNote] @p1 as varchar(40),@p2 as varchar(50)ASSET NOCOUNT ONdeclare @mystr as varchar(2000) Select @mystr = int_notes from orderheader where order_nbr = @p1set @mystr = convert(varchar(20), getdate(), 0) + ' >>>Proof emailed to ' + @p2 + ' mdw ' + @mystrUpdate orderheader set int_Notes =@mystr where order_nbr = @p1GO3) -2 WRITETEXT versionCREATE PROCEDURE [dbo].[CT_setIntNote] @p1 as varchar(40),@p2 as varchar(50)ASSET NOCOUNT ONdeclare @mystr as varchar(8000)DECLARE @ptrval binary(16)--get the pointer SELECT @ptrval = TEXTPTR(head_int_notes) from order_header where head_order_nbr = @p1--get the existing noteSelect @mystr = head_int_notes from order_header where head_order_nbr = @p1--add the new parts inset @mystr = convert(varchar(20), getdate(), 0) + ' >>>Proof #1 emailed to ' + @p2 + ' .mdw ' + @mystr--save back WRITETEXT order_header.head_int_notes @ptrval @mystrGO |
|
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2007-04-27 : 12:25:00
|
| I used profiler to see what came in and found thatmy TextDada = exec CT_setIntNote @P1 = '8', @P2 = 'p'On the calling side,I have triedSqlDbType.VarCharandSqlDbType.CharThe later gave me the right value in immediate window as ?arParms(0).Value string '881412' and arParms(1).Value string 'psomething@shsd.com'What/who took the rest of my string away? |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2007-04-27 : 14:25:45
|
Just guessing, but maybe you need to specify a varchar length here, which may be defaulting to 1:TryarParms(0) = New SqlParameter("@P1", SqlDbType.VarChar, ParameterDirection.Input)arParms(0).Value = JobIDarParms(1) = New SqlParameter("@P2", SqlDbType.VarChar, ParameterDirection.Input)arParms(1).Value = MailtoEmaile4 d5 xd5 Nf6 |
 |
|
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2007-04-27 : 15:14:00
|
| I have triedSqlDbType.VarChar(10)but that is not the right syntax in dotnet.Well, I did find out the "real" cause, but I am more confused than ever!When I stepped into SQLHelper.ExecuteNonQuery or ExecuteDataSet, I saw the parameter array size =1! If I manually changed it to 10, then every thing worked!I have never had to changed any thing in MS Application Block Data Access lib, and the same class/dll is in production use. |
 |
|
|
|
|
|
|
|