<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'(Jython) MSSQL stored procedure with parameters not working' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread '(Jython) MSSQL stored procedure with parameters not working' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Thu, 24 May 2012 00:28:04 -0700</pubDate>
    <lastBuildDate>Thu, 24 May 2012 00:28:04 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>(Jython) MSSQL stored procedure with parameters not working</title>
      <link>http://www.programmersheaven.com/mb/python/427137/427137/jython-mssql-stored-procedure-with-parameters-not-working/</link>
      <description>Hi -&lt;br /&gt;
&lt;br /&gt;
I've been thrown in at the deep end with a Jython project (actually Sikuli X, but I need to use Jython to record test results in an MSSQL2008 DB).  This is my first foray into the world of Jython, and I simply can't find anyone else with the same issue on the net....&lt;br /&gt;
&lt;br /&gt;
I'm able to pull data from my MSSQL 2008 DB using a stored proc with no parameters, but if I try to store data using a stored procedure with parameters, I'm getting issues!&lt;br /&gt;
&lt;br /&gt;
I'm running out of time on this project and I'm a bit desperate!&lt;br /&gt;
&lt;br /&gt;
Jython code:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;import sys&lt;br /&gt;
from com.ziclix.python.sql import zxJDBC&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
strDataSource, strDBUser, strDBPassword, strDBVersion = "jdbc:sqlserver://192.168.127.130;databaseName=Aut
oTest", "*******", "******", "com.microsoft.sqlserver.jdbc.SQLServerDriver"&lt;br /&gt;
objConnection = zxJDBC.connect(strDataSource, strDBUser, strDBPassword, strDBVersion)&lt;br /&gt;
objCursor = objConnection.cursor()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
objCursor.callproc(("AutoTest", "dbo", "dbo.UserCreate"), {"@UserName":"UserName", "@UserPassword":"Password", "@FName":"FName", "@SName":"SName"})&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
objCursor.close()&lt;br /&gt;
print "complete"&lt;br /&gt;
&lt;br /&gt;
objConnection.close()&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
This is calling the following stored procedure on MSSQL 2008:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;CREATE PROCEDURE [dbo].[UserCreate] &lt;br /&gt;
	-- Add the parameters for the stored procedure here&lt;br /&gt;
	@UserName			varchar(50),&lt;br /&gt;
	@UserPassword		varchar(50),&lt;br /&gt;
	@FName				varchar(50),&lt;br /&gt;
	@SName				varchar(50)&lt;br /&gt;
AS&lt;br /&gt;
BEGIN&lt;br /&gt;
	-- SET NOCOUNT ON added to prevent extra result sets from&lt;br /&gt;
	-- interfering with SELECT statements.&lt;br /&gt;
	SET NOCOUNT ON;&lt;br /&gt;
&lt;br /&gt;
    -- Insert statements for procedure here&lt;br /&gt;
	INSERT INTO		Users&lt;br /&gt;
		(&lt;br /&gt;
			UserName,&lt;br /&gt;
			UserPassword,&lt;br /&gt;
			FName,&lt;br /&gt;
			SName&lt;br /&gt;
		)&lt;br /&gt;
	VALUES&lt;br /&gt;
		(&lt;br /&gt;
			@UserName,&lt;br /&gt;
			@UserPassword,&lt;br /&gt;
			@FName,&lt;br /&gt;
			@SName&lt;br /&gt;
		)&lt;br /&gt;
END&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
This gives me the following error:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;zxJDBC.Error: Procedure or function 'UserCreate' expects parameter '@UserName', which was not supplied. [SQLCode: 201], [SQLState: S0004]&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
I've also tried the following:&lt;br /&gt;
&lt;br /&gt;
objCursor.callproc(("AutoTest", "dbo", "dbo.UserCreate"), ["UserName", "Password", "FName", "SName"])&lt;br /&gt;
&lt;br /&gt;
A SQL Trace shows the following being passed through by Microsoft JDBC(4):&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;declare @p1 int&lt;br /&gt;
set @p1=2&lt;br /&gt;
exec sp_prepexec @p1 output,NULL,N'EXEC AutoTest.dbo.UserCreate '&lt;br /&gt;
select @p1&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A quick VBScript I knocked up to use the same stored procedure works perfectly…&lt;br /&gt;
&lt;br /&gt;
If you can offer any help at all, I'll be very very grateful!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/427137/427137/jython-mssql-stored-procedure-with-parameters-not-working/</guid>
      <pubDate>Wed, 01 Feb 2012 01:56:29 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>
