Unable To Submit More Than 8000 Characters With Stored Procedure
Jul 20, 2005
Hi all,
I have a internet page written in asp to submit into authors
curriculum vitae publications (title, author, year, etc.).
If the author submit less than 8000 characters it functions OK, but If
the author try's to submit more than 8000 characters the asp page does
not return an error but the text is not saved in the database or,
sometimes, it returned a "Typ mismatch" error.
Here is the sp:
---------------------------------------------------------------------
CREATE PROCEDURE sp_CV_publications
(
@formCommand
nvarchar(255)='process',
@id numeric=null,
@id_personint=null,
@typPubID tinyint= NULL,
@publicationstext=null
)
AS
if @formCommand='process'
begin
INSERT INTO CV_publications(
idperson,
typPubID,
publications
)
VALUES (
@id_person
@typPubID,
@publications
);
select 1 as status, @@IDENTITY AS insertedID, * FROM
CV_publications WHERE id=@@IDENTITY
end
----------------------------------------------------------------------------
The server is running IIS5 and SqlServer 2000
Any ideas ???
View 1 Replies
ADVERTISEMENT
Dec 19, 2005
Problem about pass a big string (over 8000 characters) to a variable nvarchar(max) in stored procedure in SQL 2005!
I know that SQL 2005 define a new field nvarchar(max) which can stored 2G size string.
I have made a stored procedure Hellocw_ImportBookmark, but when I pass a big string to @Insertcontent , the stored procedure can't be launch! why?
create procedure Hellocw_ImportBookmark @userId varchar(80), @FolderId varchar(80), @Insertcontent nvarchar(max)
as declare @contentsql nvarchar(max); set @contentsql=N'update cw_bookmark set Bookmark.modify(''declare namespace x="http://www.hellocw.com/onlinebookmark"; insert '+ @Insertcontent+' as last into (//x:Folder[@Id="'+@FolderId+'"])[1]'') where userId='''+@userID+''''; exec sp_executesql @contentsql;
View 2 Replies
View Related
Dec 19, 2005
Problem about pass a big string (over 8000 characters) to a variable nvarchar(max) in stored procedure in SQL 2005!
I know that SQL 2005 define a new field nvarchar(max) which can stored 2G size string.
I have made a stored procedure Hellocw_ImportBookmark, but when I pass a big string to @Insertcontent , the stored procedure can't be launch! why?
----------------------13-------------------------------------
create procedure Hellocw_ImportBookmark
@userId varchar(80),
@FolderId varchar(80),
@Insertcontent nvarchar(max)
as
declare @contentsql nvarchar(max);
set @contentsql=N'update cw_bookmark set Bookmark.modify(''declare namespace x="http://www.hellocw.com/onlinebookmark"; insert '+
@Insertcontent+' as last into (//x:Folder[@Id="'+@FolderId+'"])[1]'') where userId='''+@userID+'''';
exec sp_executesql @contentsql;
View 6 Replies
View Related
Aug 1, 2007
Hi..
I m working on MS SQL Server 2000.
I am trying to pass a list of numbers to a stored procedure to be used with 'IN()' statement.
I was doing something like..
Create Procedure proc
(
@Items varchar(100) --- List of numbers
)
AS Begin
Declare @SQL varchar(8000)
Set @SQL =
'
Select Query......
Where products IN (' + @items + ') '
'
Exec (@SQL)
This stored procedure is working fine, but when i m adding more required stuff to that, the size exceeds 8000, & it gives the error "Invalid operator for data type. Operator equals add, type equals text."
Can any1 please help me out with this ASAP??
View 4 Replies
View Related
Mar 12, 2008
I have this sql statement in a stored procedure
SELECT @sql=@sql + '''' + convert(varchar(100), pivot) + ''' = ' + stuff(@sumfunc,charindex( '(', @sumfunc )+1, 0, ' CASE ' + @pivot + ' WHEN ' + @delim + convert(varchar(100), pivot) + @delim + ' THEN ' ) + ', ' FROM ##pivot
in the statement, where @sql is defined as DECLARE @sql varchar(Max). the problem is that this statement produces results that are in excess of 8000 characters and the results are truncated. Is there anyway to avoid this? I know that it's not possible to user ntext/text as a local variable, and if i try to return the result as an ouput paramater, only the first result is returned.
my code is based off of this article http://www.sqlteam.com/article/dynamic-cross-tabs-pivot-tables
Thanks for any suggestions.
View 4 Replies
View Related
Oct 14, 2007
if a user chooses to request a lot of customers to report on say from a multi select listbox - what is the best way to pass this list to my stored proc? Looking for suggestions.
thanks,
View 3 Replies
View Related
May 23, 2006
Hi,
I have a MDX query which is of an aprox length of 10000 characters. I
have to execute the query from within the stored procedure in sql. To
run this query I use the openrowset method.
If the length of my query is less than 8000 characters my query
executes perfectly, but the moment it exceeds 8000 characters it stop
working. Please suggest a solution for the same.
Sample Code:
declare @mdxqry varchar(8000)
declare @SearchCond varchar(8000)
set @SearchCond = @SearchCond + '
[ProductsAccounts].CurrentMember.properties("AS Date") <= "' + @TDate
+ '" '
set @mdxqry = '''WITH ' +
'MEMBER [Measures].[Difference] as ''''[Measures].[Expected Interest
Amount] - [Measures].[Adjusted Interest]'''' ' +
'MEMBER [Measures].[Loan Closed within Report Period] as ' +
'''''iif(cdate([ProductsAccounts].CurrentMember.properties("Closed
Date")) < cdate("' + @ToDate + '"), "Yes", "No")''''' +
'MEMBER [Measures].[ClosedBeforeLastInstallment] as
''''iif([Measures].[Loan Closed Before Last Instal]=1, "Yes", "No")''''
' +
'SELECT ' +
'{[Measures].[Expected Interest Amount], [Measures].[Adjusted
Interest], [Measures].[Difference], ' +
'[Measures].[Zero Interest Transactions],
[Measures].[ClosedBeforeLastInstallment], ' +
'[Measures].[Loan Closed within Report Period]} ON 0, '
set @mdxqry = @mdxqry +
'{Filter([ProductsAccounts].[Account Id].Members, (' + @SearchCond +
'))} on 2, ' +
@BranchFilter +
'FROM InterestAnalysis'''
set @mdxqry = 'SELECT a.* FROM
OpenRowset(''MSOLAP'',''DATASOURCE="SERVERNAME"; Initial
Catalog="DATABASENAME";'',' + @mdxqry + ') as a'
exec(@mdxqry)
I have already tried splitting my query into smalled chunks and
executing it, but still I face the same problem.
This is how I have Done it:
declare @mdxqry1 varchar(8000)
declare @mdxqry2 varchar(8000)
declare @SearchCond varchar(8000)
set @SearchCond = @SearchCond + '
[ProductsAccounts].CurrentMember.properties("AS Date") <= "' + @TDate
+ '" '
set @mdxqry1 = '''WITH ' +
'MEMBER [Measures].[Difference] as ''''[Measures].[Expected Interest
Amount] - [Measures].[Adjusted Interest]'''' ' +
'MEMBER [Measures].[Loan Closed within Report Period] as ' +
'''''iif(cdate([ProductsAccounts].CurrentMember.properties("Closed
Date")) < cdate("' + @ToDate + '"), "Yes", "No")''''' +
'MEMBER [Measures].[ClosedBeforeLastInstallment] as
''''iif([Measures].[Loan Closed Before Last Instal]=1, "Yes", "No")''''
'
set @mdxqry2 = 'SELECT ' +
'{[Measures].[Expected Interest Amount], [Measures].[Adjusted
Interest], [Measures].[Difference], ' +
'[Measures].[Zero Interest Transactions],
[Measures].[ClosedBeforeLastInstallment], ' +
'[Measures].[Loan Closed within Report Period]} ON 0, '
set @mdxqry2 = @mdxqry2 +
'{Filter([ProductsAccounts].[Account Id].Members, (' + @SearchCond +
'))} on 2, ' +
@BranchFilter +
'FROM InterestAnalysis'''
set @mdxqry2 = 'SELECT a.* FROM
OpenRowset(''MSOLAP'',''DATASOURCE="SERVERNAME"; Initial
Catalog="DATABASENAME";'',' + @mdxqry + ') as a'
exec(@mdxqry1 + @mdxqry2)
Thanks in Advance
Charu
View 5 Replies
View Related
Nov 14, 2005
In SS 2000 it seems that there is no variable data type that can hold more than 8000 characters (varchar) or 4000 unicode characters (nvarchar). I've seen posts where multiple variables are spliced together to extend this limit. I am looking at performing string manipulations in an sproc and I need to be able to deal with the full 2GB/1GB limit of text and ntext field types. Is this possible? How do you deal with that?
View 14 Replies
View Related
Nov 25, 2007
Hi,
I had a VARCHAR(MAX) parameter declared in my stored procedure and trying to concatenat single column from a table which has~500 rows into a string and keep in this variable, if i am not mistaken, i read that the VARCHAR(MAX) actually can hold up to 2GB of data, so it make me confuse why the variable which i declared as MAX size, can only hold up 8000 characters, any idea?
Regards,
Derek
View 10 Replies
View Related
Nov 28, 2006
Hello everyone,
trying to use stored procedure for my datagrid.
in there i have the parameter that i would like to combine with wild character to retrieve some data..Does not work.
Please help to come up with right syntax...
here is the code:
SELECT First_Name, Last_Name, Address, City, Customer_ID, Company_Name, State, ZIP, Phone_Number_1, Phone_Number_2, Email
FROM v2_Customers
WHERE (City = @search_text) OR
(First_Name = @search_text) OR
(Last_Name LIKE '%'+@search_text) OR
(Address = @search_text)
where @search_text is the parameter,
thank you!
View 5 Replies
View Related
Mar 31, 2006
Hi,
I have a clr stored procedure that takes in 2 parameters, input xml and a query name. The stored procedure transforms the xml with a the xslt for the given query name (stored in a database). I am currently using and output parameter that is of type NVarChar(4000) to retrieve the xml in .net.
This all works fine unless the xml that is being transformed is greater than 4000 characters which will happen. Are there any ways of returning a string/xml greater than 4000 characters (in the region of 60-70k characters).
Thanks for your help
N
View 7 Replies
View Related
May 10, 2007
I would like SQL Server 2000 to distinguish between uppercase and lowercase letters, but only within a single stored procedure. Also, at the end of the sp, I want the original collation to be restored. How will I implement this in my sp?
View 3 Replies
View Related
Jul 30, 2007
hi everyone ive written a stored procedure which returns a value depending on the i/p parameterive executed it in the object browser but i cant extract it from the stored proc to the front end create procedure checking ( @username varchar(20), @password varchar(20) ,@result int out)asif @username ='admin'set @result = 1else set @result = 0 return @resultGOand this is what i wrote in the code behind SqlCommand check = new SqlCommand("checking",con);//checking is the stored procedure check.CommandType = CommandType.StoredProcedure; check.Parameters.Add(new SqlParameter("@username", SqlDbType.VarChar)).Value = TxtUsername.Value; check.Parameters.Add (new SqlParameter("@password", SqlDbType.VarChar)).Value = TxtPassword.Value; check.Parameters.Add(new SqlParameter("@result", SqlDbType.Int)).Value = 0;int status = ( Convert.toint32 )check.executenonquery();// the line which is prolly causing the error , can u tell me what should be written here? the status returns -1
View 2 Replies
View Related
Jun 4, 2004
I tried to create a stored procedure but instead of opening up to a new stored procedure it displays an exist stored procedure. I erased the code and typed in my code now i received this error message.
MS SQL-DMO (ODBC SQLState:42000)
Error 2729: Procedure ‘spUpdate_date_time’ group number 1 already exists
in the database. Choose another procedure name
Does anyone know how I can fix this?
Your help is appreciated
View 2 Replies
View Related
Jan 2, 2007
Hi everyone
I am trying something that should be so simple but I cant get it to work. I am calling a stored procedure to lock a table and update a counter. I have tried to follow the exact code use in the MSDN examples but it doesnt work and always returns VT_EMPTY. It also returns a closed recordset so attempting to close it fails. The database is updated correctly and there are no exceptions just no return value.
Here is the stored procedure
CREATE PROCEDURE GETMODELID AS
DECLARE @i INT
BEGIN TRANSACTION
SET @i=(SELECT ModelID from tblModelID WITH (HOLDLOCK,TABLOCKX))+1
UPDATE tblModelID SET ModelID = @i
COMMIT TRANSACTION
RETURN @i
GO
Here is the ADO written in C++.
TDatabase DB;
try
{
if(DB.Open()==false)
{
AfxMessageBox(DB.m_ErrStr);
return FALSE;
}
_variant_t vtEmpty2 (DISP_E_PARAMNOTFOUND, VT_ERROR);
_CommandPtr spCMD;
CREATEiNSTANCE(spCMD,Command);
spCMD->ActiveConnection = DB.m_Cnn;
spCMD->CommandText = "GETMODELID" ;
spCMD->CommandType = adCmdStoredProc;
spCMD->Parameters->Refresh();
_RecordsetPtr spRS;
_variant_t vRa;
spRS = spCMD->Execute( &vRa, &vtEmpty2, adCmdStoredProc );
_variant_t rtn(DEF_PARAM(spCMD,0L));
DB.Close();
return (int) rtn;
}
View 3 Replies
View Related
Aug 25, 2006
Hi All,
In my application on click of Delete button, actually I am not deleting the record. I am just updating the flag. But before updating the record I just want to know the dependency of the record ie. if the record I am deleting(internally updating) exists any where in the dependent tables, it should warn the user with message that it is available in the child table, so it can not be deleted. I want to check the dependency dynamically. For that I have written the following procedure. But it is updating in both cases.
CREATE proc SProc_DeleteRecord
@TableName varchar(50),
@DeleteCondition nVarchar(200)
As
Begin
Begin Transaction
Declare @DelString nvarchar(4000)
set @DelString = 'Delete from ' + @TableName + ' where ' + @DeleteCondition
execute sp_executeSql @DelString
RollBack Transaction --because i donot want to delete the record in any case
If @@Error <> 0
Begin
select '1'
End
Else
Begin
Declare @SQLString nvarchar(4000)
set @SQLString = 'Update ' + @TableName + ' set DeletedFlag=1 where ' + @DeleteCondition
execute sp_executeSql @SQLString
select '0'
End
End
Thanks & Regards
Bijay
View 4 Replies
View Related
Mar 30, 2006
I'm using a form that has a dropdown control. This dropdown control has items that can be selected that serves as a filter for displaying results on the page that is returned from a stored procedure call. I'm having trouble finding a way to execute the stored procedure to display the filtered results everytime a different item in the dropdown gets selected. Currently, the form does get submitted and the selected item does get saved, but the stored procedure never gets executed on a postback. Any ideas on resolving this issure? Your help is much appreciated.
View 1 Replies
View Related
Feb 15, 2006
Hi all,
When I try to open a connection it gives me error "Stored Procedure sp_sdidebug not found"
Can anyone help me in this respect?
I was running the same application with the SQL Server 2005 only earlier when it was running.But now after I reinstalled VS.NET & SQL Server I am getting this error.What could be the problem?
Please help... I am badly stuck up.
PAM
View 3 Replies
View Related
Mar 12, 2007
I get the following error in a log file created in the osql command:
Msg 3201, Level 16, State 1, Server KAC2KGS2, Procedure usp_Kaman_Full_SqlDB_Backup, Line 150
Cannot open backup device 'x:Servername_master_sqlbu_200703101930.bkf'.
Device error or device off-line. See the SQL Server error log for more
details.
Msg 3013, Level 16, State 1, Server KAC2KGS2, Procedure usp_Kaman_Full_SqlDB_Backup, Line 150
BACKUP DATABASE is terminating abnormally.
The device is established in a CMD file right before the osql command is started that starts my stored procedure. The CMD in this file is:
for /f "tokens=15 delims=." %%i in ('ipconfig^|find "IP Address"^|find "192.168"') do set SUBNET=%%i
:loop
if exist x: net use x: /del
net use x: \192.168.%SUBNET%.1ackup
if not ERRORLEVEL 1 (
goto continue
) else (
echo FAILED TO CONNECT TO BACKUP SERVER >> "%SystemDrive%LogFiles\%Computername%.log"
sleep 60
goto loop
)
:continue
echo IP ADDRESS OBTAINED
Echo delete old log file if it exists
if exist %3\%computername%_kaman_full_sqldb_backup_old.log del /Q %3\%computername%_kaman_full_sqldb_backup_old.log
Echo Rename log file to old.log
rename %3\%computername%_kaman_full_sqldb_backup.log %computername%_kaman_full_sqldb_backup_old.log
echo backup SQL Databases on server will start now
osql -E -n -d %1 -i %2kaman_full_sqldb_backup.sql -h-1 -o %3\%Computername%_kaman_full_sqldb_backup.log
In the stored procedure I try to use the x: drive and that does not work. I have tried obtaining the \192.168.x.x address and that only works on some of my servers. All are running SQL 2000, some are using Win2K and Win2003. It does not seem to matter. One of them that is using Win2003 only fails occationally.
I notice when I do a
exec master..xp_cmdshell 'x:'
The system cannot find the drive specified.
Yet, when I go to the server there is an x drive.
I am using the sqlserv user to run the job and that use is an administrator on the local machine. This is a virtual machine. We add the X before the osql and drop it after the command finishes.
Any help would be appreciated. Thanks, dbmsql
View 6 Replies
View Related
Nov 2, 2015
Created a report that displays the Maximum Response time (example of value 00:00:00) which is directly pulled from the Stored proc.When I ran the report, the column displays blank values.I am not sure if I should add any conversion to the Response value in the report.
View 2 Replies
View Related
Jun 11, 2015
We are executing a SSIS package using a xp_cmdshell command in a SP as shown below. This package does consumes time to execute almost 90 minutes and does get executed successfully too. But the strange thing is we don't get the result in @result variable just because somehow the next sql statement after the below highlighted statement doesn't get executed at all. Â After checking execution stats for the SP using the query attached below we observed that somehow the SP vanishes out of the execution stats for the server.
 SELECT @cmd = 'dtexec /FILE "D:Program FilesMicrosoft SQL Server100DTSPackages.....PopulateReport.dtsx"'     Â
 SELECT @cmd = @cmd + ' /Decrypt T@!0er '     Â
 SELECT @cmd = @cmd + ' /set package.variables[vAppID].Value;' + CONVERT(VARCHAR(10),@appId)     Â
 SELECT @cmd = @cmd + ' /set package.variables[vDBName].Value;' + '"' + @db + '"'     Â
 SELECT @cmd = @cmd + ' /set package.variables[vBuildMFF].Value;' + CONVERT(VARCHAR(10),@BuildMFF)     Â
Â
[code]....
View 6 Replies
View Related
Jan 10, 2008
Hello
We seem to be having junk characters within our SQL server 2005 database for data related to East Asian countries. However, if we are to manually mess around within Excel we will be able to decipher these characters.
Following is a sample:
Îâê»
mr ºÃ²Ã‡¿
ms Ãõá°
»§Ã“ê´º
Ö콨Ò»
Can you please let me know the best way of fixing this issue?
View 1 Replies
View Related
Apr 29, 2015
A trigger existed on the job steps table which captured any changes before and after. The insert table was limited changes to 4000 characters.
SQL Server 2012 SP2 Enterprise Edition (11.0.5058.0) on Windows Server 2008 R2
At some point a few months ago we encountered an issue where we hit a size limit of ~4000 characters on the amount of text we could enter into a Transact-SQL step of an Agent job. Attempting to create a job like this with sp_add_job will produce the error
Msg 50000, Level 16, State 10, Procedure sp_add_jobstep_internal, Line 255
String or binary data would be truncated.
Adding the job step via SSMS yields
Alter failed for JobStep 'xxx'. (Microsoft.SqlServer.Smo)
Additional information:
An exception occurred while executing a Transact-SQL statement or batch (Microsoft.SqlServer.ConnectionInfo)
String or binary data would be truncated.
The statement has been terminated. (Microsoft SQL Server, Error: 8152)
I've checked sp_add_jobstep_internal, sp_add_jobstep and the sysjobsteps table and all references to the command field are nvarchar(max). We can run the same job creation code without error on a SQL Server 2008 R2 Enterprise Edition machine and two SQL Server 2012 SP2 Developer Edition boxes. All our 2012 servers were fresh installs, not upgrades.
View 4 Replies
View Related
Apr 29, 2015
SQL Server 2012 SP2 Enterprise Edition (11.0.5058.0) on Windows Server 2008 R2
At some point a few months ago we encountered an issue where we hit some size limit on the amount of text we could enter into a Transact-SQL step of an Agent job. Attempting to create a job like this with sp_add_job will produce the error
Msg 50000, Level 16, State 10, Procedure sp_add_jobstep_internal, Line 255
String or binary data would be truncated.
Adding the job step via SSMS yields
Alter failed for JobStep 'xxx'. (Microsoft.SqlServer.Smo)
Additional information:
An exception occurred while executing a Transact-SQL statement or batch (Microsoft.SqlServer.ConnectionInfo)
String or binary data would be truncated.
The statement has been terminated. (Microsoft SQL Server, Error: 8152)
I've checked sp_add_jobstep_internal, sp_add_jobstep and the sysjobsteps table and all references to the command field are nvarchar(max). We can run the same job creation code without error on a SQL Server 2008 R2 Enterprise Edition machine and two SQL Server 2012 SP2 Developer Edition boxes. All our 2012 servers were fresh installs, not upgrades.
View 9 Replies
View Related
Apr 26, 2007
Hi,I'm trying to do retrieve some data from a table where the content isin Greek, however, thequery is not working. It's a very simple statement, but I'm missingsomething.Here is the table...if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[REPORT_LOCALE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[REPORT_LOCALE]GOCREATE TABLE [dbo].[REPORT_LOCALE] ([XL_REPORT_ID] [int] NULL ,[TEXT_NAME] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_ASNULL ,[LOCALE] [int] NULL) ON [PRIMARY]GOThe first statment shows me a number of rows. I copied the content ofthe Text_Name column and pasteit into QA to form the second statement. However, the second statementreturns no data.SELECT * FROM Report_LocaleSELECT * FROM Report_Locale WHERE Text_Name = 'Λογ.Διαχ. – ΤÏ?.-Î*Ï?ουπ.-Διαφ.'Hopefully the Greek characters will display properly within this post,but the idea is basically to take the Greek text and build that into aquery. I can do the remainder later once I understand why this doesnot work as I expect. I realise my expectation is based on doingthings in English so I need to understand the differences. We've donethis for various other languages using other character sets, which iswhy I am puzzled.Any pointers ?ThanksRyan
View 1 Replies
View Related
Jun 6, 2005
Hello,
I'm not sure if it's the setup I did wrong, but I can't seem to get my
text datatype in my database to store more than 900 characters.
I'm trying to setup a news database for my website, which will populate
the information into a datagrid. To test, I manually added a news
item in the database through the visual studio 2003 gui. I
immediately noticed a problem as the I was getting an error after a
long news item saying:
"The value you entered is not consistent with the data type or length of the column, or over grid buffer limit."
I couldn't find anthing to set the buffer limit and the datatype is
"text" filled with simple text in the column. As a further test,
I
simply entered 12334567890123... up to 900 characters and still
recevied the error.
I would appreciate someone leading me in the right direction on this one.
Thanks a lot.
View 1 Replies
View Related
Nov 1, 2007
Hi all - I'm trying to optimized my stored procedures to be a bit easier to maintain, and am sure this is possible, not am very unclear on the syntax to doing this correctly. For example, I have a simple stored procedure that takes a string as a parameter, and returns its resolved index that corresponds to a record in my database. ie
exec dbo.DeriveStatusID 'Created'
returns an int value as 1
(performed by "SELECT statusID FROM statusList WHERE statusName= 'Created')
but I also have a second stored procedure that needs to make reference to this procedure first, in order to resolve an id - ie:
exec dbo.AddProduct_Insert 'widget1'
which currently performs:SET @statusID = (SELECT statusID FROM statusList WHERE statusName='Created')INSERT INTO Products (productname, statusID) VALUES (''widget1', @statusID)
I want to simply the insert to perform (in one sproc):
SET @statusID = EXEC deriveStatusID ('Created')INSERT INTO Products (productname, statusID) VALUES (''widget1', @statusID)
This works fine if I call this stored procedure in code first, then pass it to the second stored procedure, but NOT if it is reference in the second stored procedure directly (I end up with an empty value for @statusID in this example).
My actual "Insert" stored procedures are far more complicated, but I am working towards lightening the business logic in my application ( it shouldn't have to pre-vet the data prior to executing a valid insert).
Hopefully this makes some sense - it doesn't seem right to me that this is impossible, and am fairly sure I'm just missing some simple syntax - can anyone assist?
View 1 Replies
View Related
Mar 3, 2008
Hi all,
I have 2 sets of sql code in my SQL Server Management Stidio Express (SSMSE):
(1) /////--spTopSixAnalytes.sql--///
USE ssmsExpressDB
GO
CREATE Procedure [dbo].[spTopSixAnalytes]
AS
SET ROWCOUNT 6
SELECT Labtests.Result AS TopSixAnalytes, LabTests.Unit, LabTests.AnalyteName
FROM LabTests
ORDER BY LabTests.Result DESC
GO
(2) /////--spTopSixAnalytesEXEC.sql--//////////////
USE ssmsExpressDB
GO
EXEC spTopSixAnalytes
GO
I executed them and got the following results in SSMSE:
TopSixAnalytes Unit AnalyteName
1 222.10 ug/Kg Acetone
2 220.30 ug/Kg Acetone
3 211.90 ug/Kg Acetone
4 140.30 ug/L Acetone
5 120.70 ug/L Acetone
6 90.70 ug/L Acetone
/////////////////////////////////////////////////////////////////////////////////////////////
Now, I try to use this Stored Procedure in my ADO.NET-VB 2005 Express programming:
//////////////////--spTopSixAnalytes.vb--///////////
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlConnection As SqlConnection = New SqlConnection("Data Source = .SQLEXPRESS; Integrated Security = SSPI; Initial Catalog = ssmsExpressDB;")
Dim sqlDataAdapter As SqlDataAdapter = New SqlDataAdaptor("[spTopSixAnalytes]", sqlConnection)
sqlDataAdapter.SelectCommand.Command.Type = CommandType.StoredProcedure
'Pass the name of the DataSet through the overloaded contructor
'of the DataSet class.
Dim dataSet As DataSet ("ssmsExpressDB")
sqlConnection.Open()
sqlDataAdapter.Fill(DataSet)
sqlConnection.Close()
End Sub
End Class
///////////////////////////////////////////////////////////////////////////////////////////
I executed the above code and I got the following 4 errors:
Error #1: Type 'SqlConnection' is not defined (in Form1.vb)
Error #2: Type 'SqlDataAdapter' is not defined (in Form1.vb)
Error #3: Array bounds cannot appear in type specifiers (in Form1.vb)
Error #4: 'DataSet' is not a type and cannot be used as an expression (in Form1)
Please help and advise.
Thanks in advance,
Scott Chang
More Information for you to know:
I have the "ssmsExpressDB" database in the Database Expolorer of VB 2005 Express. But I do not know how to get the SqlConnection and the SqlDataAdapter into the Form1. I do not know how to get the Fill Method implemented properly.
I try to learn "Working with SELECT Statement in a Stored Procedure" for printing the 6 rows that are selected - they are not parameterized.
View 11 Replies
View Related
Dec 6, 2006
Hi I am totally new programing and thought I would try my hands on ASP.NET 2.0. I created a web form that would take user information and submit it to a SQL database. However I am not sure how to properly setup the SQL connection. What am I doing wrong?default.aspx.cs:using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page{ protected void MultiView1_ActiveViewChanged(object sender, EventArgs e) { } protected void Button1_Click1(object sender, EventArgs e) { String ConnStr = "Data Source=TECATE;Initial Catalog=subscribe_mainSQL;Integrated Security=True"; String SQL = "Insert into main (email,fname,lname,userid,status) values ('" + email.Text + "', " + fname.Text + "','" + lname.Text + "','" + userid.Text + "','" + degree.SelectedItem.Value + "')"; }} default.aspx:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableSessionState="True" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Email Sign Up Page</title></head><body style="text-align: center"> <form id="form1" runat="server"> <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0" OnActiveViewChanged="MultiView1_ActiveViewChanged"> <asp:View ID="signup" runat="server"> <br /> <table style="background-color: #f0f0f0" width="450"> <tr> <td style="width: 18px; height: 23px"> </td> <td style="font-weight: bold; font-size: medium; width: 383px; color: black; font-family: verdana; height: 23px"> Email Subcribe System</td> <td style="width: 19px; height: 23px"> </td> </tr> </table> <table style="color: white; font-family: verdana; background-color: #5d7b9d" width="450"> <tr> <td style="width: 19px; height: 20px"> </td> <td align="center" style="width: 153px; height: 20px"> </td> <td align="left" style="width: 18px; height: 20px"> </td> <td style="width: 115px; height: 20px"> </td> </tr> <tr> <td style="width: 19px"> </td> <td align="left" style="width: 153px"> <asp:Label ID="Label1" runat="server" Font-Names="Verdana" Font-Size="X-Small" Text="First Name:"></asp:Label></td> <td align="left" style="width: 18px"> </td> <td align="left" style="width: 115px"> <asp:Label ID="Label2" runat="server" Font-Names="Verdana" Font-Size="X-Small" Text="Last Name:"></asp:Label></td> </tr> <tr> <td style="width: 19px; height: 26px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="fname" ErrorMessage="*" ForeColor="White"></asp:RequiredFieldValidator></td> <td align="left" style="width: 153px; height: 26px"> <asp:TextBox ID="fname" runat="server" MaxLength="20"></asp:TextBox></td> <td align="left" style="width: 18px; height: 26px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="lname" ErrorMessage="*" ForeColor="White"></asp:RequiredFieldValidator></td> <td align="left" style="width: 115px; height: 26px"> <asp:TextBox ID="lname" runat="server" MaxLength="20"></asp:TextBox></td> </tr> <tr> <td style="width: 19px; height: 9px"> </td> <td align="left" style="width: 153px; height: 9px"> <asp:Label ID="Label3" runat="server" Font-Names="Verdana" Font-Size="X-Small" Text="10 Digit USC ID:"></asp:Label></td> <td align="left" style="width: 18px; height: 9px"> </td> <td align="left" style="width: 115px; height: 9px"> <asp:Label ID="Label4" runat="server" Font-Names="Verdana" Font-Size="X-Small" Text="USC Email:"></asp:Label></td> </tr> <tr> <td style="width: 19px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="uscid" ErrorMessage="*" ForeColor="White"></asp:RequiredFieldValidator></td> <td align="left" style="width: 153px"> <asp:TextBox ID="uscid" runat="server" MaxLength="10"></asp:TextBox></td> <td align="left" style="width: 18px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="email" ErrorMessage="*" ForeColor="White"></asp:RequiredFieldValidator></td> <td align="left" style="width: 115px"> <asp:TextBox ID="email" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 19px"> </td> <td align="left" style="width: 153px"> <asp:Label ID="Label5" runat="server" Font-Names="Verdana" Font-Size="X-Small" Text="Degree Status:"></asp:Label></td> <td align="left" style="width: 18px"> </td> <td align="left" style="width: 115px"> <asp:Label ID="Label6" runat="server" Font-Names="Verdana" Font-Size="X-Small" Text="Confirm USC Email:"></asp:Label></td> </tr> <tr> <td style="width: 19px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="degree" ErrorMessage="*" ForeColor="White"></asp:RequiredFieldValidator></td> <td align="left" style="width: 153px"> <asp:DropDownList ID="degree" runat="server"> <asp:ListItem></asp:ListItem> <asp:ListItem>Undergraduate</asp:ListItem> <asp:ListItem>Graduate</asp:ListItem> <asp:ListItem Value="PhD">Ph.D</asp:ListItem> </asp:DropDownList> </td> <td align="left" style="width: 18px"> </td> <td align="left" style="width: 115px"> <asp:TextBox ID="confirmemail" runat="server"></asp:TextBox></td> </tr> <tr> <td style="width: 19px; height: 21px"> </td> <td align="left" style="width: 153px; height: 21px"> </td> <td align="left" style="width: 18px; height: 21px"> </td> <td align="right" style="width: 115px; height: 21px"> </td> </tr> <tr> <td style="width: 19px; height: 21px"> </td> <td align="left" style="width: 153px; height: 21px"> <br /> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="email" ControlToValidate="confirmemail" ErrorMessage="*Emails Do Not Match" Font-Names="Verdana" Font-Size="X-Small" ForeColor="White"></asp:CompareValidator> </td> <td align="left" style="width: 18px; height: 21px"> </td> <td align="right" style="width: 115px; height: 21px"> <asp:Button ID="Button1" runat="server" CommandName="NextView" Font-Bold="True" Font-Names="Verdana" Font-Size="Small" OnClick="Button1_Click1" Text="Submit" /></td> </tr> </table> <div align="center"> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:subscribe_mainSQLConnectionString %>" InsertCommand="INSERT INTO [main] (, [uscid], [fname], [lname], [degree]) VALUES (@email, @uscid, @fname, @lname, @degree)" OldValuesParameterFormatString="original_{0}" SelectCommand=" WHERE = @original_email AND [uscid] = @original_uscid AND [fname] = @original_fname AND [lname] = @original_lname AND [degree] = @original_degree"> <InsertParameters> <asp:Parameter Name="email" Type="String" /> <asp:Parameter Name="uscid" Type="String" /> <asp:Parameter Name="fname" Type="String" /> <asp:Parameter Name="lname" Type="String" /> <asp:Parameter Name="degree" Type="String" /> </InsertParameters> </asp:SqlDataSource> </div> </asp:View> <asp:View ID="thankyou" runat="server"> <br /> <table style="background-color: #f0f0f0" width="450"> <tr> <td style="width: 18px; height: 23px"> </td> <td style="font-weight: bold; font-size: medium; width: 383px; color: black; font-family: verdana; height: 23px"> Email Subcribe System</td> <td style="width: 19px; height: 23px"> </td> </tr> </table> <div align="center"> <br /> <br /> <br /> <asp:Label ID="Label7" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="Small" Text="Thank you for registering."></asp:Label> </div> </asp:View> </asp:MultiView><div align="center"> </div> </form></body></html>
View 6 Replies
View Related
Nov 14, 2014
I am new to work on Sql server,
I have One Stored procedure Sp_Process1, it's returns no of columns dynamically.
Now the Question is i wanted to get the "Sp_Process1" procedure return data into Temporary table in another procedure or some thing.
View 1 Replies
View Related
Jan 29, 2015
I have some code that I need to run every quarter. I have many that are similar to this one so I wanted to input two parameters rather than searching and replacing the values. I have another stored procedure that's executed from this one that I will also parameter-ize. The problem I'm having is in embedding a parameter in the name of the called procedure (exec statement at the end of the code). I tried it as I'm showing and it errored. I tried googling but I couldn't find anything related to this. Maybe I just don't have the right keywords. what is the syntax?
CREATE PROCEDURE [dbo].[runDMQ3_2014LDLComplete]
@QQ_YYYY char(7),
@YYYYQQ char(8)
AS
begin
SET NOCOUNT ON;
select [provider group],provider, NPI, [01-Total Patients with DM], [02-Total DM Patients with LDL],
[Code] ....
View 9 Replies
View Related
Sep 19, 2006
I have a requirement to execute an Oracle procedure from within an SQL Server procedure and vice versa.
How do I do that? Articles, code samples, etc???
View 1 Replies
View Related
Mar 8, 2007
Hi
I am trying to create a Quiz system and i need to put the user's Unique ID in the Result Data Table, so that the when they submit there results it puts there Unique ID by the side so that they can view it in there profile, and not anyone elses.
Thanks
Gareth Cork
View 1 Replies
View Related