Basics With Stored Procedures.....please

Jan 2, 2004

Hi there, I'm still fairly new to asp.net / c#





I've setup my stored procedure, but now what?


I want to display the information (only one record it will return) on the page / NOT using a datagrid or list, just simple.....I guess using an asp:label?????


Could someone tell me what I need to do!!!





Also, are there any proper resources out there that just show you right out of the box howto insert / update / delete with sp's?, show / view, just proper simple source code?





THANKS!





my code:


// Creating the database connection


SqlConnection objConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn_main"]);





// Creating the stored procedure 4 the webpage


// Instantiate a Sql Command


SqlCommand webpage_view = new SqlCommand("stpr_webpage_view", objConn);


// Declare that the T-SQL statement that will be executed is a stored procedure


// Use a CommandType.Text to execute a T-SQL Query


webpage_view.CommandType = CommandType.StoredProcedure;


SqlParameter webpage_id_parm = webpage_view.Parameters.Add("@webpage_id", SqlDbType.Int);


webpage_id_parm.Value = "1";


// Create a SqlDataAdapter to manage the connection and retrieve the data


SqlDataAdapter da_1 = new SqlDataAdapter();


// Instantiate a Dataset that will hold the data retrieved from the database using the select command


DataSet ds_webpage = new DataSet();


da_1.SelectCommand = webpage_view;


// Retrieve the data into the dataset using the SqlDataAdapter.Fill command


da_1.Fill( ds_webpage, "webpage_title" );


DataView dv2 = ds_webpage.Tables[0].DefaultView;


if ( !this.IsPostBack ) {


this.DataBind ( );


}

View 1 Replies


ADVERTISEMENT

Oracle Stored Procedures VERSUS SQL Server Stored Procedures

Jul 23, 2005

I want to know the differences between SQL Server 2000 storedprocedures and oracle stored procedures? Do they have differentsyntax? The concept should be the same that the stored proceduresexecute in the database server with better performance?Please advise good references for Oracle stored procedures also.thanks!!

View 11 Replies View Related

Stored Procedures 2005 Vs Stored Procedures 2000

Sep 30, 2006

Hi,



This Might be a really simple thing, however we have just installed SQL server 2005 on a new server, and are having difficulties with the set up of the Store Procedures. Every time we try to modify an existing stored procedure it attempts to save it as an SQL file, unlike in 2000 where it saved it as part of the database itself.



Thank you in advance for any help on this matter



View 1 Replies View Related

All My Stored Procedures Are Getting Created As System Procedures!

Nov 6, 2007



Using SQL 2005, SP2. All of a sudden, whenever I create any stored procedures in the master database, they get created as system stored procedures. Doesn't matter what I name them, and what they do.

For example, even this simple little guy:

CREATE PROCEDURE BOB

AS

PRINT 'BOB'

GO

Gets created as a system stored procedure.

Any ideas what would cause that and/or how to fix it?

Thanks,
Jason

View 16 Replies View Related

Basics Of SQL

Oct 24, 2005

Hi, I am used to using Access but I need to learn SQL for larger web sites. I normally build the database in Access visually, but how do you do this with SQL? I just installed SQL developer and I can't find the area that builds the database.

View 3 Replies View Related

Basics

Jun 11, 2007

Hi, I m new to sql server...
I want to know the difference b/w unicode class and character class.. Pls help... That is difference b/w varchar and nvarchar

anup

View 2 Replies View Related

SQL DB Basics...maybe

Jun 28, 2007

I've a number of SQL DBs that are managed by a php browser front end. These were developed in php/html to a SQL 2000 DB.



The DB and tables have been recreated in SQL 2005, permissions are that of the owner (SA) and the php code has been adjusted accordingly. Although the reading of the data is okay, I cannot update nor insert data from the php script through to the SQL 2005 DB whereas it works perfectly fine through the same php script and SQL 2000.



Obviously, there's something I'm not seeing??? There are no noticable messages and the last transaction does show up in the php display.... closing the portal then reopening, the record is "gone" and the SQL 2005 DB remains untouched.

View 5 Replies View Related

Basics

Jan 21, 2007

Hi there,

I've recently bought Visual Studio 2005, and I got SQL server 2005. I have no idea how to work it. I can't even find where you make a table.

Any basic help about SQL server 2005 is needed.

Thanks,
AliQ

View 3 Replies View Related

How To Search And List All Stored Procs In My Database. I Can Do This For Tables, But Need To Figure Out How To Do It For Stored Procedures

Apr 29, 2008

How do I search for and print all stored procedure names in a particular database? I can use the following query to search and print out all table names in a database. I just need to figure out how to modify the code below to search for stored procedure names. Can anyone help me out?
 SELECT TABLE_SCHEMA + '.' + TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'

View 1 Replies View Related

SQL Server Basics

Jan 9, 2007

Hi,
I am a DB2 DBA and plan to learn SQL Server for professional reasons. But I am not able to find the material to begin with. So I would be greatful if you guys can send me links to start with the architecture and other basics of SQL server. I just want to accquire additional skills so that it can help me in the future.

View 1 Replies View Related

Sybase Basics

May 19, 2008

Hi Gurus,

I am not sure is this the right forum to get solution to my question.

From where i can get sysbase basics.
I am posting this query in this forum coz this forum and gurus in this forum had helped me in lot critical situtions.

Hope this happens now also..

Thanks,
ServerTeam

View 2 Replies View Related

Clustering Basics

Mar 20, 2008

hi all,

can you help me with some informations...

in a case of clustering, is instance of sqlserver installed on each of the nodes, or there is only one instance shat is "shared" between node servers?

or it depends on the type if clustering?

tnx in adv!

View 2 Replies View Related

Restoring To A New DB - The Basics

Sep 13, 2006

Hiya,

I've recently gotten into the administration side of SQL and am muddling my way through it as best I can. We have a DB server with three or four databases on it. Maintenance routines do a full backup of each one nightly and weekly and put all sets into one backup (.bak) file.

I've never had to restore them, but I thought I'd put myself through a test run since this is unexplored territory for me and I would prefer not to have to learn in an emergency.

A scenario I can foresee is where I'd have to restore just one table, perhaps to a new location (i.e. not overwrite the live db, just bring up a copy of part of it elsewhere so I can do a data dump from some old data). But when I go to 'restore database' or 'restore file/filegroups' and select the file, it seems to really want to restore the full backup directly over top of the existing database. If I try to restore it to a new, non-existent database, I get an error about how 'logical file master is not a part of database 'new-backup'), and if I try to restore it to a new db that I've created, I get an error about how the databases don't match.

It seems to me that my problem is a philosophical one - perhaps I don't understand the nature of backups, but I feel like what I'm trying to do is pretty simple. I want to take the full backup of database A and restore it, in part (or in full if I have to) to new database B. What do I need to do to accomplish this?

Thanks for indulging me - this must be brain-dead stuff for most of you!

View 8 Replies View Related

Using A Stored Procedure To Query Other Stored Procedures And Then Return The Results

Jun 13, 2007

Seems like I'm stealing all the threads here, : But I need to learn :) I have a StoredProcedure that needs to return values that other StoredProcedures return.Rather than have my DataAccess layer access the DB multiple times, I would like to call One stored Procedure, and have that stored procedure call the others to get the information I need. I think this way would be more efficient than accessing the DB  multiple times. One of my SP is:SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived,     I.Expired, I.ExpireDate, I.Deleted, S.Name AS 'StatusName', S.ItemDetailStatusID,    S.InProgress as 'StatusInProgress', S.Color AS 'StatusColor',T.[Name] AS 'TypeName',    T.Prefix, T.Name AS 'ItemDetailTypeName', T.ItemDetailTypeID    FROM [Item].ItemDetails I    INNER JOIN Item.ItemDetailStatus S ON I.ItemDetailStatusID = S.ItemDetailStatusID    INNER JOIN [Item].ItemDetailTypes T ON I.ItemDetailTypeID = T.ItemDetailTypeID However, I already have StoredProcedures that return the exact same data from the ItemDetailStatus table and ItemDetailTypes table.Would it be better to do it above, and have more code to change when a new column/field is added, or more checks, or do something like:(This is not propper SQL) SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived,     I.Expired, I.ExpireDate, I.Deleted, EXEC [Item].ItemDetailStatusInfo I.ItemDetailStatusID, EXEC [Item].ItemDetailTypeInfo I.ItemDetailTypeID    FROM [Item].ItemDetails IOr something like that... Any thoughts? 

View 3 Replies View Related

How To Save Stored Procedure To NON System Stored Procedures - Or My Database

May 13, 2008

Greetings:

I have MSSQL 2005. On earlier versions of MSSQL saving a stored procedure wasn't a confusing action. However, every time I try to save my completed stored procedure (parsed successfully ) I'm prompted to save it as a query on the hard drive.

How do I cause the 'Save' action to add the new stored procedure to my database's list of stored procedures?

Thanks!

View 5 Replies View Related

Distribution Agent Basics?

Nov 6, 2006

Hey everyone,
 sorry for the lame questions, but:
1) I have a transactional replication service set up. However, whenever we select a new table or column within a table to replication to the subscribers, the changes never seem to get picked up unless we make an actual change within some of the other data. Any idea why this is? Even after I've reinitialized snapshots, the new changes don't want to proprogate to teh subscribers until data is actually changed.
2) where do I need to go to manually stop and restart a a distribution agent to force these changes to be proprogated without having to change any data within the tables?
Thanks
 

View 1 Replies View Related

2005 Database Basics

Apr 24, 2007

Hi,

Im trying to justify to people in a meeting why we have to break down some large financial instrument tables in a new database design we are implementing.

They have currently broken the tables down into instruments1 & instruments2, containing approx 300 & 150 columns respectively (further columns will be added!). then they have a view that joins virtually all of these columns. I've asked for the tables to be broken down into more logical groups. they are saying that this will cost more overhead as their views will span more tables. i also complained about the width of the rows, but they claimed that sql 2005
will not have a problem as only 1/3 of the row will have any data at one point so will not cause an overhead. can someone give me some definate points on this relating to 2005 as I am fairly new to it.

can someone help me with the basic points why they should be split into more logical groups.

they are also intending on adding millions of records a year to this table and partioning it will different filegroups. Should you place the indexes for tables on different filegroups as well?

View 1 Replies View Related

SSIS Basics Working With The IDE

Apr 1, 2008

Is the intent of Microsoft to enforce a vertical presentation of the SSIS Control Flow, Data Flow etc? I like to work down and to the right and I am having problems with the connectors (precedent) or in DTS 2000 world Success or On Success implied. Is there away to connect from the lower center anchor point to the side of the next object in the flow? For some reason, I can't get a similiar look to DTS 2000 environment (going from the bottom middle of the object to the side anchor pint (small box) symbol to the left. It wants to anchor on the bottom right, left, or middle, if going horizontally. I must be missing something, here??

Thanks again!

Skyseek


View 2 Replies View Related

Failure Audit - The Basics

Aug 19, 2006

Hi,

I'm a bit new to administering a SQL Server and this seems like a pretty basic question, but I'm not sure how to phrase it for the searches. So I apologize for seeking an indulgence...

I have SQL Server 2005 Standard edition running on a server exposed to the Internet. A handful of clients have to connect to it via TCP/IP using SQL Server Studio and ODBC links. But my windows logs are chok-full of failure audits of what I presume to be your garden variety crackers trying default passwords -- several times a minute.

What's the best solution to this, and how would I go about implementing it? Restrict TCP/IP access to certain IP ranges? Is there a 'max login attempts' somewhere? The server uses SQL authentication (not windows) if that makes a difference.

Thanks for the help!

View 1 Replies View Related

Transactions - Back To Basics

Oct 30, 2006

Hi all,

I am having no end of trouble with transactions in the package which i am building. I now just want to go back to basics and see if someone can tell me where i should set specific transaction options.

Firstly, my package runs a for each loop which loops through a directory of directories. In each of the sub directories there are 2 files. The first steps in the loop are to check if a folder has been processed previously, if so then it moves it to a specified directory. The reason that this is done first is that i cannot move the directory whilst it is being read in the foreach loop, so i pass the path to the next iteration of the loop. There is another file system move directory task outwith the foreach loop to deal with the last directory.

Once this has been done, i parse the file name of the xls file within the directory to get a serial number which is assigned to a variable.

The next step is where i envisage that the transactions should be implemented:
I have a sequence container which contains 2 data flow tasks to be run in parallel. each of these reads data from a seperate work sheet in the xls file. and writes it to a database table. Each dataflow task consists of an excel source task, derived column task, look up task (used to derive an ID from the serial number stored in the variable), and an oledb destination.

Upon completion, if the sequence container fails i want to set the destination folder path to the qurantine location. If it succeeds i want to copy the csv file contained in the same directory to a seperate location and then set the out put folder to the archive location.

What i need to know is where do i set the transaction option if i want to roll back the data that has been inserted into the database if either data flow task fails?

Please somebody help, as this is not working at all.

Many thanks,

Grant

View 18 Replies View Related

Connection Pooling Basics.

Feb 15, 2008



We have an large SQL database being accessed by a C# application. Each hit on the database opens a connection then closes it when done. We are currently experiencing errors when more than 20 users access the database at one time. One of the things I am wondering is if we are using connection pooling. From BOL I am lead to believe connection pooling is off by default. Can I turn on connection pooling as a default in SQL Server or do I pass 'pooling=true' as a parameter on each connection string?

Thanks.

View 5 Replies View Related

Stored Procedure Being Saved In System Stored Procedures

Apr 7, 2006

We recently upgraded to SQL Server 2005. We had several stored procedures in the master database and, rather than completely rewriting a lot of code, we just recreated these stored procedures in the new master database.

For some reason, some of these stored procedures are getting stored as "System Stored Procedures" rather than just as "Stored Procedures". Queries to sys.Objects and sys.Procedures shows that these procs are being saved with the is_ms_shipped field set to 1, even though they obviously were not shipped with the product.

I can't update the sys.Objects or sys.Procedures views in 2005.

What effect will this flag (is_ms_shipped = 1) have on my stored procedures?

Can I move these out of "System Stored Procedures" and into "Stored Procedures"?

Thanks!

View 24 Replies View Related

How Can I Call One Or More Stored Procedures Into Perticular One Stored Proc ?

Apr 23, 2008

Hello friends......How are you ? I want to ask you all that how can I do the following ?
I want to now that how many ways are there to do this ?



How can I call one or more stored procedures into perticular one Stored Proc ? in MS SQL Server 2000/05.

View 1 Replies View Related

SSIS And Stored Procedures Results Stored In #Tables

Mar 26, 2008

Hello
I'm start to work with SSIS.

We have a lot (many hundreds) of old (SQL Server2000) procedures on SQL 2005.
Most of the Stored Procedures ends with the following commands:


SET @SQLSTRING = 'SELECT * INTO ' + @OutputTableName + ' FROM #RESULTTABLE'

EXEC @RETVAL = sp_executeSQL @SQLSTRING


How can I use SSIS to move the complete #RESULTTABLE to Excel or to a Flat File? (e.g. as a *.csv -File)

I found a way but I think i'ts only a workaround:

1. Write the #Resulttable to DB (changed Prozedure)
2. create data flow task (ole DB Source - Data Conversion - Excel Destination)

Does anyone know a better way to transfer the #RESULTTABLE to Excel or Flat file?

Thanks for an early Answer
Chaepp

View 9 Replies View Related

MS SQL Basics: Insert Into Multiple Tables At Once.

Aug 15, 2006

I'm trying to do something very basic here but I'm totally new to MS SQL Server Manager and MS SQL in general.
I'm using the Database Designer in MS SQL Server Manager. I created two tables with the following properties:
Schedule (ScheduleID as UniqueIdentifier PK, Time as dateTime)
Course (CourseID as UniqueIdentifier PK, Name as VarChar(50))
I create a relationship by dragging the PK from the first table over to the second and I link on ScheduleID to CourseID columns (I'm not certain what type of relationship is created here N:N?). It appears to work, I can do a Select * and join the two tables to get a joined query.
The problem starts when I try to populate the tables: a course will have a schedule. I can't seem to get the rows to populate across both tables. I try to select the pk from the first table and insert it into the second but it complians about it not being a uniqueidentifier. I know this is very basic but I can't seem to find this very basic tutorial anywhere.
I come from the Oracle world of doing DB's so if you have some examples that relate across that would be great or better yet if you can point me to a good reference for doing M$ DB stuff that would be great.
Thanks.

View 9 Replies View Related

SSIS Layout/Design Basics

Nov 29, 2007



I have 3 'separate' but related processes that I am developing in SSIS. Each process shares a few global variables and connection objects. None of the processes depend on inputs or outputs from the other processes. However, there is a sequence order in which they are exectuted.

Should I develop these three process in the same package or 3 separate packages in the same solution?

From the point of view of sharing the same variables and connection objects, maybe just one package? If so, would it be advise to use the toolkit's 'Sequence Container' to ensure the order in which the 3 processes are run? I noticed that 'global variables' are limited to the scope of individual packages so it would appear that a variable can't be shared between packages in the same solution? I was also thinking that in terms of configuration settings, there might be an advantage of keeping everything in the same package. The only disadvantage I can think of in relation to keeping everything in the same package is that the design layout might look a bit cluttered.

I'm tending to think one package here but would welcome comments and suggestions from those that have experience of similar design scenerios.

Thanks,
Clive

View 4 Replies View Related

MS SQL Stored Procedures Inside Another Stored Procedure

Jun 16, 2007

Hi,
 Do you know how to write stored procedures inside another stored procedure in MS SQL.
 
Create procedure spMyProc inputData varchar(50)
AS
 ----- some logical
 
 procedure spMyProc inputInsideData varchar(10)
AS
   --- some logical
  ---  go
-------

View 5 Replies View Related

Calling Stored Procedures From Another Stored Procedure

May 8, 2008

I am writing a set of store procedures (around 30), most of them require the same basic logic to get an ID, I was thinking to add this logic into an stored procedure.

The question is: Would calling an stored procedure from within an stored procedure affect performance? I mean, would it need to create a separate db connection? am I better off copying and pasting the logic into all the store procedures (in terms of performance)?

Thanks in advance

John

View 5 Replies View Related

VB2008 SQL Database Programming Basics Question

Feb 25, 2008

I am writing a program where I will be calculating some values that need to be sent to an SQL Database row by row. I am new to SQL Database programming and I was wondering what I need to include in my program as far as declarations, and data adapter connections in order to accomplish this. Or is it enough to already be connected to my database via a manual data connection? I also need to know some of the basic commands for inserting a new row, and adding data under existing columns, prior to moving on to the next row and repeating the process. If you can point me to a basic example that demonstrates this, including how to properly close out my database, I would appreciate it. If you know of a good VB2008 SQL Database book that covers all the basic & some advanced SQL Database programming, I would be interested in that as well.
For Example:
Row# Name CalcA CalcB CalcC CalcD
1 ? ? ? ? ?
2 ? ? ? ? ?
Etc€¦
Thanks.
Techno
Visual Studio Express 2008 user

View 5 Replies View Related

Calling A Stored Procedure Inside Another Stored Procedure (or Nested Stored Procedures)

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

Only Functions And Extended Stored Procedures Can Be Executed From Within A Function. Sp_executesql Is A Extended Stored Prod

May 15, 2008

i have created the folowing function but keep geting an error.

Only functions and extended stored procedures can be executed from within a function.

Why am i getting this error!

Create Function myDateAdd
(@buildd nvarchar(4), @avdate as nvarchar(25))
Returns nvarchar(25)
as
Begin
declare @ret nvarchar(25)
declare @sqlval as nvarchar(3000)

set @sqlval = 'select ''@ret'' = max(realday) from (
select top '+ @buildd +' realday from v_caltable where realday >= '''+ @avdate +''' and prod = 1 )a'

execute sp_executesql @sqlval
return @ret
end

View 3 Replies View Related

Stored Procedures

Jun 17, 2006

hi

i need to use only one stored procedure and access many tablesso how write a stored procedure for that dohelp me looking forward for a reply to the earliest i am developing web page using asp.net using c# and sqlserver as backend

looking forward for a replygayathri

View 1 Replies View Related

Stored Procedures

Dec 15, 2006

I am interested to know about stored procedures in Mssql .Can anyone please help me out.
 
Thanx in advance. 

View 1 Replies View Related







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