Showing posts with label properly. Show all posts
Showing posts with label properly. Show all posts

Monday, March 19, 2012

Calling a Stored Procedure that does an insert and returns one value

Hi !

I have trying to do an insert with a subroutine that calls a stored procedure, but it doesn' t run. The page loads properly but nothing is inserted in the table of the database, no errors appears after submit the form.

<asp:Button id="SubmitButton" OnClick="Send_data" Text="Submit" runat="server"/>

Here is the code:


Sub Send_data(Sender As Object, E As EventArgs)

Dim CmdInsert As New SqlCommand("new_user1", strConnection)
CmdInsert.CommandType = CommandType.StoredProcedure

Dim InsertForm As New SqlDataAdapter()
InsertForm.InsertCommand = CmdInsert

CmdInsert.Parameters.Add(New SqlParameter("@.RETURN_VALUE", SqlDbType.bigint, 8, "User_id"))
CmdInsert.Parameters("@.RETURN_VALUE").Direction = ParameterDirection.ReturnValue

CmdInsert.Parameters.Add(New SqlParameter("@.e_mail", SqlDbType.varchar, 50, "e_mail"))
CmdInsert.Parameters("@.e_mail").Value = mail.Text()

End Sub

What it lacks?cmdInsert.ExecuteNonQuery|||Now when I submit the form the error is:

System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is Closed.

But the connection is available because in my webform appears several 'dropdownlists' with data from the database... And the 'strConnection' is the correct 'SqlConnection' declared before this subroutine like this: Dim strConnection As New SqlConnection(ConfigurationSettings.AppSettings("myConn"))|||If I put this runs:


...
strConnection.open()
cmdInsertar.ExecuteNonQuery
strConnection.close()

End Sub

Is this a good way of doing the insert with the called SP?
Why is not enough with this?:


Dim CmdInsert As New SqlCommand("new_user1", strConnection)

Thursday, March 8, 2012

Callback function seems not to work in MSDE setup

Hello, I'm installing MSDE and I can't seem to get the callback function to work properly. My program behaves as if the callback function is not being called at all. As a result, when the setup fails I only get the 1603 return code and no information on w
hat went wrong.
I understand from the documentation that the callback function has to have the signature
UINT __declspec(dllexport) callback(HANDLE hinstall, UINT uExitCode)
and be stored in a DLL created by the ExtendedStoredProcedure Dll option in Visual Studio .Net. Also, the Dll has to be stored in the temp directory and referenced as dll name!function name on the command line. All this is true for my callback. But the ca
llback seems never to be called. Any idea what could be going on, or how I can investigate?
Thanks.
I thought that the callback was just the same as a standard Windows DLL
callback function (which is probably the same as an Extended Stored
Procedure). You might try using depends.exe to see what name your DLL is
actually using to export the function, just to make sure it's not being
mangled in any way. Also make sure that you use the GetTempPath API to get
the temp directory.
Jim
"Jon Webb" <anonymous@.discussions.microsoft.com> wrote in message
news:A98E4BD8-9F24-4B50-885B-13C426190862@.microsoft.com...
> Hello, I'm installing MSDE and I can't seem to get the callback function
to work properly. My program behaves as if the callback function is not
being called at all. As a result, when the setup fails I only get the 1603
return code and no information on what went wrong.
> I understand from the documentation that the callback function has to have
the signature
> UINT __declspec(dllexport) callback(HANDLE hinstall, UINT uExitCode)
> and be stored in a DLL created by the ExtendedStoredProcedure Dll option
in Visual Studio .Net. Also, the Dll has to be stored in the temp directory
and referenced as dll name!function name on the command line. All this is
true for my callback. But the callback seems never to be called. Any idea
what could be going on, or how I can investigate?
> Thanks.
>