Acces Return Value From A StoredProcedure - How?

Apr 6, 2008

hi

i have a stored procedure witch Returns 0 or 1 dependig if exists some rows

how can i acces that value in code behind? i tryied all, command.ExecuteScalar(), command.ExecuteNonQuery() but none works

i need something like if(command.GetReurnValue) .... else ....

thanks in advance

View 3 Replies


ADVERTISEMENT

StoredProcedure Return Value

Jun 27, 2006

I am using SQL Server 2005 now and I have a table with following columns.
ID, FirstName, LastName, Email
"ID" is the primary key (int) and is set auto generated (1 increment)
I have a StoredProcedure to insert a new record.
CREATE PROCEDURE Candidate_Create @FName nvarchar(255), @LName nvarchar(255), @Email nvarchar(255)ASINSERT INTO Candidate (FirstName, LastName, Email)VALUES (@FName, @LName, @Email)GO
I want the ID to be returned as the same time when a new record is inserted, how can I do it ? Is it possible ?
 

View 3 Replies View Related

StoredProcedure And DataSet Return

Feb 9, 2008

I am trying to write a function for some source to make a call out to and fill a RadioButtonList.  I am running into a few problems though that I need assistance on.  (I am new to DataSets)
Here is the function to fill the RBL:
 1 Private Function GetDataSet(ByVal QuestionID As Integer, ByVal QuestionType As Integer, ByVal LocaleID As Integer, ByVal GroupingNum As Integer) As DataSet
2 Dim cnn As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
3 Dim cmd As New SqlCommand
4 cmd.CommandText = "usp_responses_sel"
5 cmd.CommandType = Data.CommandType.StoredProcedure
6
7 ' Fill usp_ with Parameters
8 cmd.Parameters.AddWithValue("QuestionID", QuestionID)
9 cmd.Parameters.AddWithValue("LocaleID", LocaleID)
10 cmd.Parameters.AddWithValue("GroupingNum", GroupingNum)
11
12 Dim da As New SqlDataAdapter
13 da.SelectCommand = cmd
14 Dim ds As New DataSet
15 da.Fill(ds, "response")
16 Return ds
17 End Function


So my issue is with line 15 [da.Fill(ds, "response")].  I pulled this function from somewhere else and am trying to tailor it to my needs.  However, I do not understand what I need to do with this line and it keeps bombing out.  I thought this references the DB Table but in my case, the SP has several tables joined together.  Is this how I reference it from the calling source code?  Please assist.
Also, I am having problems understanding the binding process from the calling source.  Here is my code that calls the function:1 Dim ds As DataSet = GetDataSet(CType(e.Item.DataItem("question_id").ToString, Integer), QuestionTypeID.Value, intLocale, 2)
2 rblResponses2.DataSource = ds
3 rblResponses2.DataBind()
 
What do I need to do with it from here and how can I work with it after it's bound?
Thanks

View 5 Replies View Related

Can't Acces

Oct 26, 2005

my colleague is using visual studio (VB) and making windows applications. we used same connection string but i can't connect to the sql server.

i am using visual studio(2003) .net(C#) and making web applications. this is the code.

System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection ();
// TODO: Modify the connection string and include any
// additional required properties for your database.
//conn.ConnectionString = "integrated security=SSPI;data source=cerebrum;persist security info=False;initial catalog=dals";
conn.ConnectionString="Server=cerebrum;Initial Catalog=dals;User Id=sa;";
try
{
conn.Open();
// Insert code to process data.
Label1.Text="Connection successful";
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}

and i'm getting this error
SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

Source Error:


Line 91: throw ex;
Line 92: }
Line 93: finally

View 4 Replies View Related

Acces To SQL Guidence?

Feb 3, 2007

OK I have been trying on my own to move from Access to SQL express/Developer. I have not found much in the way of guidence. Any suggestions? I would rank myself as fairly advanced with Access but just a newby to the SQL products... I keep blasting into walls and issues in the SQL world and would rather learn from someone elses' hardship rather than re-invent what has been undoubtably been already discovered.

I do fairly advanced reports and Large imports, Hence the need for developer rather than express, since the express import facility is hopelessly crippled. Even the developer SSIS is not well doccumented and seems pretty buggy and hard to use, even with the wizzards, As for reports.... well I'm expecting that to be a fairly had road to climb also...

View 3 Replies View Related

Acces To SQL Server On Another Domain

Feb 27, 2008

I've got a website with authentication mode "forms". Now I need access to the database to authenticate the user. The SQL Server is located in another domain than IIS.I don't know how to establish a trusted connection with the SQL Server. How can I establish this?

View 2 Replies View Related

Remote Acces To Sql Server

Dec 14, 2001

Hi

I would like to acces a SQL Server that is on a web server.

I want to to this to be able to control the sql server and database to create table, trigger...

For "MySql" i use DBTools to acces my database via the web, is there something i can use like BdTools to acces the Sql Server 2000 database

I'm new to SQL so can somebody can tell me what to do!

Thanks

View 4 Replies View Related

SQL/Acces Record Locking

Dec 9, 2005

I am running an Access 2000 front end and MS SQL2000 as a backend and I am having problems with record locking.

I have just found out that If you use ODBC then Access acts as if No Locks are set. In an ideal world I need the record to be locked by a user as soon as they move onto it. If not as soon as they start editing it?

Cheers.

View 2 Replies View Related

How Do I Programatically Acces A Database With A '-' In The Name?

Jul 23, 2005

use this-is-a-stupid-namereturns an errorFor that matterselect *from this-is-a-stupid-name.dbo.anytablereturns an errorI've tried single quoted, double quotes, escaping. In the SQL editor I canselect the name from the dropdown and I'm OK - but I'm writing a perlscript to connect to the database.I didn't create the database and don't know how it was created.--Message posted via http://www.sqlmonster.com

View 2 Replies View Related

Acces Multiple Servers

Nov 15, 2006

Hi,

I need to access a table from another server in my procedure...I am now connected to say SERVERA...I need to access another table SERVERB.TABLE2 in the same procedure...

Is there a way to do that...

I need to connect to two servers from the same procedure to get data..

Please get back

Thanks,

View 3 Replies View Related

Acces An Remote OLAP Server

Jul 22, 2005

I try to access an OLAP Server from a remote compute, using ADO MD Library with following string conection :
"Datasource=SERVNAME; Provider=msolap; Initial Catalog=FoodMart 2000;"
I recive the following error code: -2147467259 (0x80004005), "Unspecified error"
Can sombody help me

View 4 Replies View Related

Order By (boolean) Acces-sqlserver

Dec 19, 2005

I have migrated an Access database to SQLserver,

all seems ok,
but I found that an "order by" on a boolean Access field, is reverse under
SQLserver ?
I had to add "desc" to my code "order by field desc" to retrieve the correct display.

Could someone confirm this ? I am very surprised.

Thanks, Pierre.

View 4 Replies View Related

Acces Data Of A Linked Server

Apr 30, 2007

Hi, I'm using Sql 2000 and I have a linked server called SRVSRV.
The link works because I can list all tables.

How can I access the data i'm trying:


SELECT * FROM [SRVSRV].Database.Table

And it don't works.
What am i doing bad?
Thanks.

View 4 Replies View Related

Convert A Ms Acces (mdb) Database To SQL Server

Feb 19, 2008

Hi there.

How can i convert a Ms Access Database file (.mdb) to an SQL Server 2005 Database ????

is there any tools ?? or what ever can help me .

Thank you.

View 2 Replies View Related

Acces To A File That Is Locked By Another Process

Mar 15, 2006

I am writing a package to process perfmon logs. The issue I have come across is that the perfmon process holds onto the log file and SSIS fails because it wants to exclusive read access. Is there any way of getting SSIS to not take an exclusive read on the file.

I can read the file in notepad fine but not SSIS.

View 1 Replies View Related

LAN / WLAN Acces 2 SQL Server From Win CE Device

Oct 9, 2007

After an internet search I have some questions regarding SQL Server access from a mobile device via LAN / WLAN.

I will write a application in C that write data to an SQL server. First if I correct that's not possible to acces an SQL server via ODBC on Windows CE? What alternatives are there?



Stef

View 1 Replies View Related

Online Get Data From MS Acces To SQL Server

Mar 28, 2008



Hi All,
I have MS Access 97 database and SQL Server 2005 Express Edition (or SQL Server 2005 Developer Edition).
I want online get data from MS Access and upload to SQL Server.

Help me, which way I select ?
Regards

View 3 Replies View Related

Invalid Connection Error ,when Trying To Acces My Database

Jan 25, 2008

Hi friends,
            I have developed a website and uploaded the database to Remote server through Export wizard in Sqlserver 2005.everything is working fine in Sqlserver enterprise manager,  but when i tried to connect this database via web.config file to my website it is giving me error...
Server Error in '/Sales_offer' Application.


Invalid connection. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Invalid connection.Source Error:



Line 29: {
Line 30: SqlCommand mycmd=new SqlCommand("select distinct(city) from master order by city asc",myconn);
Line 31: myconn.Open();
Line 32: SqlDataReader sdr=mycmd.ExecuteReader();
Line 33: ArrayList arr=new ArrayList();Source File: d:inetpubwwwrootsales_offerindex.aspx.cs    Line: 31 Stack Trace:



[SqlException: Invalid connection.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
Sales_offer.WebForm1.bind() in d:inetpubwwwrootsales_offerindex.aspx.cs:31
Sales_offer.WebForm1.Page_Load(Object sender, EventArgs e) in d:inetpubwwwrootsales_offerindex.aspx.cs:67
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()



Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
 
 
After that when i tried to access the database through Qury analyzer it is giving me error
Msg 911, Level 16, State 1, Line 1
Could not locate entry in sysdatabases for database 'salecumoffers'. No entry found with that name. Make sure that the name is entered correctly.
But it is showing me the tables and their Contents from Remote server in enterprise manager...
waiting for ur quick response
Neeraj
 

View 13 Replies View Related

Problem With Simple Sqlclient Database Acces

Mar 10, 2008

This is a part of my project and that are my first steps. I just want to know if there is a user with "username" already in the database. The MSDN Documentation says that the ExecuteNonQuery() Method returns the number of affected rows. But if I run this code I always get x=-1. What does that mean ?

using (SqlConnection sqlcon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["web_db_1"].ConnectionString))        {            SqlCommand cmd = new SqlCommand("Select user_id From users Where username = '" + username + "'", sqlcon);            cmd.CommandType = CommandType.Text;            cmd.Connection.Open();            int x = cmd.ExecuteNonQuery();            cmd.Connection.Close();        }
 Thanks,
Party-Pansen

View 5 Replies View Related

Multi-User Acces Using SQL Server Express

Mar 27, 2008

I am new to SQL Server but have been using Access to provide Multi-User acces to a central data store. We are evaluating the replacement of Access with SQL Server. With Access we don't need any special installation; I believe that the Jet Database Engine installed locally on each user's PC allows them to work with this in a disconnected manner; we use ADO.net 2.0 with VB.net 2005.

If each user has a locally installed SQL Server Express can they all attach to a database that resides on a shared network location?

In another post on the Forum I see the following regarding multi-user access:
Our application You will need to pick a central computer that everyone will be using the access the data and attach the file to the parent instance of SQL Express on that comuter, giving it a name that you can use to access it. Then you will need to modify your connection string to connect to the named database on the central server...

Can multiple locally installed SQL Server Express instances attach to a single data store that resides on a shared network location?

If not, what permissions do I need to create a parent instance of SQL Server Express?

Thank you for helping me understand how to implement our solution.

JudiR

View 13 Replies View Related

Connection From Acces 2003 To SQL Server 2005

Dec 10, 2006

What is the fastet connection between access 2003 to sql server 2005?

View 2 Replies View Related

How To Lock The Store Procedure And Allow One Process To Acces It At A Time

Jul 20, 2005

Hello:I run one process that calls the following the store procedure andworks fine.create PROCEDURE sp_GetHostSequenceNumASBEGINSELECT int_parameter_dbf + 1FROM system_parameter_dbtWHERE parameter_name_dbf = 'seqNum'UPDATE system_parameter_dbtSET int_parameter_dbf = int_parameter_dbf + 1WHERE parameter_name_dbf = 'seqNum'ENDGOIf I run two processes that call the above store procedure, I mightoccasionally get the dirty data of int_parameter_dbt. I guess that iscaused by two processes accessing to the same resource simultaneously.Is there any way to lock the store procedure call from MSSQL Serverand allow only one process to access it at a time?Thanks for help.Best Jin

View 2 Replies View Related

Why Can't I Acces My SQL Server 2005 Db After Working With Visual Web Developer?

Apr 28, 2008

I am developing an asp.net app using visual web developer. I am using a sql server 2005 db for the back end. I have learned that I have to restart my machine if I want to work with the db in SQL Server 2005 Express after working with it in Visual Web Developer.

I am wondering why this is. I am assuming that the db is locked when it is used with VWD. Is this correct? Am I refering to it's status of "locked" correctly? Should I call this something else?

-thanks to anyone that can help

View 3 Replies View Related

Imporing Data From Acces File To SQL Express 2005

Feb 19, 2008



Hi!!
I need some help to importing Acces file to SQL 2005.

Thank's

View 1 Replies View Related

StoredProcedure

Feb 12, 2008

Hi all,
I want to learn about sp with examples,so can any one give me the best urls regarding this.and i want to write single sp for all like (insert,delete and update)in a single sp.Please guide me.
Thank You

View 1 Replies View Related

StoredProcedure

Aug 27, 2004

Hi
I use the next StoredProcedure in Access, Inserts Users to tblUsers:
INSERT INTO tblUsers ( UserName, Password, RetypePassword, Email, Comments )
VALUES (@UserName, @Password, @RetypePassword, @Email,@Comments);

How do i have to write it in SQL?
Thank's.

View 1 Replies View Related

StoredProcedure

Mar 12, 2008

Hi

I am New to Sql Server. Now i have to write two stored procedures.

Here are my requirements. If any one help please.

1)People often ask me to do this as well... change the name of the underwriter. For Mortgage Network underwriters (different than MGIC underwriters) all you need to do is:



Update mnetwork..unw_Nola set underwriter='<underwriters username>' where LoanID='<LoanID>'



So, I need you to write a stored procedure that will do exactly that. If you don't enter a loanID or username, the stored procedure should tell you that it can't complete the task and why. Also, the list of underwriters can be found in:



select LoginName from mnetwork..unw_LoginLookup where UnderwriterName = '<Name on the email>'



So for this one, you would select where underwriterName='John Brennan'.


For most usernames, it's just first initial last name (jbrennan in this case). You can make the stored procedure to both, if you want. If you enter an underwriter name, then it will translate to the loginname. If you enter the login name, it will just use that. You don't have to do all of that if you don't want. Just make sure the procedure verifies that the username is correct (in the table) and that is enough.

Tables for this storedprocedure:

Table Name:mnetwork..unw_Nola
Table Fields:LoanID,ConditionSet,Status,Revised,RevisedBy,PDFNOLA,MonthlyIncome,DocExpDate,Notes,
Underwriter,rowguid,ApprovedDate.MovedToCentera,FK_UserID,RecordDate

TablName:mnetwork..unw_LoginLookup
Table Fields: [LoginLookupID], [LoginName], [UnderwriterName], [FirstName], [LastName], [Title], [Signature], [Address1], [Address2], [Addr1], [Addr2], [City], [State], [Zip], [Phone], [Phone2], [Fax], [Email], [DefaultSet], [rowguid], [FK_UserID], [RecordDate], [Createdby], [LastUpdated], [UpdatedBy]





2)1. Block this loan

2. Grant me access to this blocked loan.

So, I need you to write either one or two stored procedures that will accomplish the following:

When a loan needs to be blocked, it needs to be added to the mnetwork..sec_BlockedLoans table

When a person needs access to that loan, their username needs to be added to the mnetwork..sec_LoanAccess table.

Tables:
1) SELECT [LoanID], [Username], [Grantor], [GrantDate] FROM [mnetwork].[dbo].[sec_LoanAccess]
2) SELECT [LoanID], [Added] FROM [mnetwork].[dbo].[sec_BlockedLoans

any one can help to write these stored procedure.

Thanks,
JT

View 1 Replies View Related

StoredProcedure In A Join

Aug 22, 2007

Hi,I'm wodering if it's possible (and the correct syntax) to make a JOIN between a Table and a SP's result. This is my code, but it goes in error in the EXEC:1 SET ANSI_NULLS ON
2 GO
3 SET QUOTED_IDENTIFIER ON
4 GO
5 -- =============================================
6 -- Author:Luca de Angelis
7 -- Create date: 22/08/2007
8 -- Description:Inserimento dei dati contabili nella tabella di log
9 -- =============================================
10 CREATE PROCEDURE dbo.InsertIntoLog_dati_contabili
11 -- Add the parameters for the stored procedure here
12 @id_gestore tinyint
13 AS
14 SET NOCOUNT ON
15 BEGIN TRANSACTION
16 INSERT INTO CEL_log_dati_contabili(numero_telefonico, anno, mese, id_gestore, id_tipo_log)
17 SELECT CEL_traffico_temp.numero_telefonico
18 , CEL_traffico_temp.anno
19 , CEL_traffico_temp.mese
20 , @id_gestore as id_gestore
21 , 1
22 FROM CEL_traffico_temp
23 INNER JOIN
24 (EXEC dbo.CEL_SimConGestoreNoFilePeriodo @id_gestore, CEL_traffico_temp.anno + CEL_traffico_temp.mese) AS tabella
25 ON CEL_traffico_temp.numero_telefonico = tabella.numero_telefonico
26
27 INSERT INTO CEL_log_dati_contabili(numero_telefonico, anno, mese, id_gestore, id_tipo_log)
28 SELECT CEL_traffico_temp.numero_telefonico
29 , CEL_traffico_temp.anno
30 , CEL_traffico_temp.mese
31 , @id_gestore as id_gestore
32 , 2
33 FROM CEL_traffico_temp
34 INNER JOIN
35 (EXEC CEL_SimNelFileNoGestore @id_gestore) AS tabella
36 ON CEL_traffico_temp.numero_telefonico = tabella.numero_telefonico
37
38 INSERT INTO CEL_log_dati_contabili(numero_telefonico, anno, mese, id_gestore, id_tipo_log)
39 SELECT CEL_traffico_temp.numero_telefonico
40 , CEL_traffico_temp.anno
41 , CEL_traffico_temp.mese
42 , @id_gestore as id_gestore
43 , 3
44 FROM CEL_traffico_temp
45 INNER JOIN
46 EXEC CEL_SimNelFileNoUtente @id_gestore AS tabella
47 ON CEL_traffico_temp.numero_telefonico = tabella.numero_telefonico
48
49 IF @@error <> 0
50 BEGIN
51 ROLLBACK TRANSACTION
52 END
53 ELSE
54 BEGIN
55 COMMIT TRANSACTION
56 END
  Help me please...

View 2 Replies View Related

IF NOT EXISTS StoredProcedure

May 14, 2008

Visual Studio 2008 Code VB
 I'm trying to create a stored procedure that will update a database table. I want to make sure that duplicate records are not inserted into the Database Table, so I used IF NOT EXISTS .  With the below code I can update the table, however, you can not add additional rows to the table.
Could someone tell me what is wrong, or how to fix it?
 
Thanks! losssoc  ALTER PROCEDURE dbo.CaseDataInsert
 
@ReportType varchar(50),@CreatedBy varchar(50),
@OpenDate smalldatetime,@Territory varchar(10),
@Region varchar(10),@StoreNumber varchar(10),
@StoreAddress varchar(200),@TiplineID varchar(50),
@Status varchar(50),@CaseType varchar(200),
@Offense varchar(200)
 
AS
BEGIN
IF NOT EXISTS(SELECT ReportType,CreatedBy,OpenDate,Territory,Region,StoreNumber,StoreAddress,TiplineID,Status,CaseType,Offense FROM CaseData)INSERT CaseData(ReportType, CreatedBy,OpenDate,Territory,Region,StoreNumber,StoreAddress,TiplineID,
Status,CaseType,Offense)VALUES(@ReportType,@CreatedBy,@OpenDate,@Territory,@Region,@StoreNumber,@StoreAddress,@TiplineID,
@Status,@CaseType,@Offense)
 
END
 

View 12 Replies View Related

How To Get Results From A Storedprocedure

Jun 11, 2005

To all,
I looked at the MS-SQL pubs sample database and execute the example
stored procedure reptq2 and I got 17 results set back. Where can I find
an example using Visual Studio DataGrid or any means to get all these
results from this SP.

Thanks,


Frank

View 3 Replies View Related

Use C# Through ADO Execute StoredProcedure

Apr 16, 2006

Hi
public static void ExecuteStoredProcedure(string SPName, ref ArrayList Parameters)        {            object result=null;            ADODB.Connection Connection = new ADODB.Connection();            ADODB.Command Command = new ADODB.Command();            Command.ActiveConnection = Connection;            Command.CommandText = SPName;            Command.CommandType = CommandTypeEnum.adCmdStoredProc;
            if (Parameters != null)            {                for (int i = 0; i < Parameters.Count; i++)                {                    Command.Parameters.Append(Parameters[i]);                }            }
            try            {                Connection.Open(ConnectionString, "", "", 0);                Command.Execute(out object RecordAffected, ref object parameters, int options ) ;//the second parameter what mean? how set it?            }            catch (Exception ex)            {                throw ex;            }            finally            {                Connection.Close();            }
        }
Thanks

View 2 Replies View Related

StoredProcedure With Parameters

May 8, 2008

Hi,
I want to know how to write stored procedure with parameters. And i want to compare this parameters.

I have DropDownList and RadioButtonList in my Web Application.

How to write Procedure passing this Two control parameters.(DropDown and RadioList).

In RadioButtonList having 5 selections.

If selection 1 happens

-- some condition

if selection2 hapens
-- some condition

similarly 3,4,5

------------------

How to write conditions in storeprocedure.

Please help me i am not having exp on storedprocedure.

Thanks


View 1 Replies View Related

Storedprocedure Not Updating The Row

Mar 23, 2008

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go






ALTER PROCEDURE [dbo].[usp_CustomerDetails]

(@Number varchar(30),
@Name varchar(30),
@City varchar(20),
@SSN varchar(20),
@CustomerID int)

AS
BEGIN
IF NOT EXISTS (SELECT * FROM CustomerDetails WHERE Name = @Name AND Number = @Number)
BEGIN
UPDATE CustomerDetails SET Number = @Number,Name = @Name,City=@City,SSN = @SSN where CustomerID = @CustomerID
END
ELSE
BEGIN
print 'CANNOT UPDATE'
END
END

This my storedproc.
My problem is when i select customerID = 1 to update and if the same row having name = @name and number =@number
Then the update should take place.

but if any other row other than CustomerID=1 having name=@name and number=@number
Then the update is should not take place.

but The above stored procedure is not working like that.

so please some one help me with this.
Thankyou
Ramya.


View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved