How Much Good Practice Is To User Asp:SqlDataSource
Nov 20, 2007
I know that <asp:SqlDataSource> is fast, but is it a good practice to use this. The sqldatasource is right there in the aspx page and the SQL for sqldatasource is also right there.
Does that not break the 3 tier model, as normally we call a database layer and we have all the SQL's there.
In one of the code in saw the following. I don't know if it is a good practice to do something like this.
<asp:DropDownList ID="CountryDropDownList" runat="server" DataSourceID="SqlDataSource2" DataTextField="PickListLabel" DataValueField="PickListValue" OnDataBound="hidePanel">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:webrepos %>"
SelectCommand="SELECT [PickListLabel], [PicklistValue] FROM [PickList_Values] WHERE (([ObjectName] = @ObjectName) AND ([FieldName] = @FieldName)) ORDER BY [AbbrCode]">
<SelectParameters>
<asp:Parameter DefaultValue="Account" Name="ObjectName" Type="String" />
<asp:Parameter DefaultValue="Country__c" Name="FieldName" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
View 5 Replies
ADVERTISEMENT
Dec 2, 2005
Hi just new here in the forum i have a question
is it a good practice to use autoincrement fields in an access database for master and detail? and for unique record identification. if not please tell why..
im currently using access and with autoincrement for unique record identification and for master and detail.. then there is a possibilities to transfer from access to mssql. will i encounter problems when migrating since i am using an autoincrement fields
in mssql is there an autoincrement fields like access?
dont be harsh ok.. just anoob trying to learn. :eek:
View 6 Replies
View Related
Mar 5, 2008
hi experts,
i have a postcode database that i need to update. the database cnotains of 6tables, the file i ahev has all the information at once, so i have to organize it and insert records into the appropriate tables.
this is the first time i'm doign this so i would like to know what the best way to do? do i need to create a stored procedure or a script, or may be something special and efficient that i do not know yet.
any advise will be very appreciated
thanks in advance
View 1 Replies
View Related
Jan 9, 2004
I would like to have a stored procedure executed once a week via a DTS package. The data I would like inserted into Table_2, which is the table where the DTS is being executed on, comes from a weekly dump from Oracle into a Table_1 via another DTS package.
I would like to only import data since the last import so I was thinking of my logic to be like this:
INSERT INTO Table_2
(Field1, Field2, ... , FieldN)
VALUES (SELECT Field1, Field2, ... , FieldN FROM Table_1 WHERE ThisDate > MAX(Table_2.ThatDate))
Does this make sense? Or do you all suggest a different mannger of accomplishing this?
View 8 Replies
View Related
Oct 11, 2006
I'm sure this has been asked plenty of times before, so I'm after a link to a good answer.
I have tens of thousands of milk crates, holding dozens of different types of milk in hundreds of locations. I am used to working with objects but not databases. For this situation however I want the security of SQLServer transactions to track, for example, when a robot moves a crate from one location to another.
I am thinking of using SQLServer as a store. On startup I want to get my ecosystem of objects out of the store. While I am running, I'll just use objects. When I change an object property I want it to securely persist. I don't want to snapshot the whole menagerie of object states, just update the values that changed. Which will sometimes include the addition or deletion of objects. How do I do this? Is there an example somewhere that does this (or approximately this)?
I use VB and have Visual Studio 2005. (Which, by the way, is stunning. I thought all that "you will use less time and code more and better" talk was just hype. But its for real. Amazing product.)
tia
John
View 1 Replies
View Related
Mar 25, 2008
Hi All,
I need to send out email when error occurs in the package. Is it a good practice to put the send email task in the event handler? Then MaximumErrorCount is set to 1. But for some reason, some time I saw more than one email are sent out. Please advise. Thanks
View 6 Replies
View Related
Jun 3, 2004
I'm searching for tips on how to alert users regarding downtime of our SQL Server. Is it good enough to alert users by email, and then shut down the service, or do you use a better approach (lock database, sp_who, one-by-one alert...)?
Thankful for all replies.
Newbie in DB administration.
View 1 Replies
View Related
Jun 20, 2006
I've got a couple guys on my team who seem to think user defined functions are a "risky" feature in SQL 2000. I've been using them for years without problems. Yeah, this one of those loaded prove me right or flame me questions ... whatever. I promise not to consider posts on MSDN forums authoritative answers to this practice question. I'm just trying to see where people stand. What I'm interested in knowing is:
Do you consider UDF's in SQL advanced, hard to figure out, hard to get right or risky?
Any cases where they've caused you more problems than other MS SQL features?
Random hints on best-practice for UDF's - where do they spead things up, slow things down?
Reasons that they are better than sliced bread / cheese spread?
View 5 Replies
View Related
Sep 30, 2006
I had to re-install Sql Server and now I can't log on. I get... Login failed for user 'JobsWeekly_Login'.I can't see anything wrong with the connection string. It used to work. Might re-installing Sql Server have got its knickers in a twist?Cheers, WT.
View 7 Replies
View Related
Jun 26, 2004
Edited by SomeNewKid. Please post code between <code> and </code> tags.
Right now i'm just trying to get the page to update SQL, but its not working no errors or anything but still not updating?!?!
Any ideas? Thanks in advance
Ben
<%
Dim cnnSimple ' ADO connection
Dim rstSimple ' ADO recordset
Set cnnSimple = Server.CreateObject("ADODB.Connection")
cnnSimple.Open Blah Blah Blah
Set rstSimple = cnnSimple.Execute("SELECT * FROM WK_DATA WHERE WEEK_NUM = 2")
%>
<input name="Submit" type="button" value="Add">
<%
If Request.Form("Submit") = "Add" Then
cnnSimple.Execute("UPDATE WK_DATA SET PRICE = (PRICE + 1) WHERE WEEK_NUM = 2")
rstSimple.update
End If
cnnSimple.Close
Set cnnSimple = Nothing
%>
View 1 Replies
View Related
Feb 13, 2006
Would be interested in any advice or comment on the issue we are experiencing with SQL 2005.
In order to test some DTS package migrations, we simply created a DTS package on SQL 2000 (using Export) to copy all database objects from one database to another.
Then we restored the source database on SQL 2005 server, migrated the DTS package, and tried to execute it.
The package migrated 'fine', ran part way, and then failed. Since then we have been unable to connect to the server (Database Engine, or Integration Services) using Windows Authentication. (Error 18456, Sev 16, State 11).
We can connect to the Database Engine using SQL Authentication (but not to Integration Services which only allows Windows Authentication).
We have been able to replicate this consistently - every annoying time we've tried it!
(Reinstalling SQL Server does 'fix' the issue ... until you try a similar package again).
View 2 Replies
View Related
Nov 19, 2007
I created a user control file with 3 properties. I would like to call this user control in a datalist control in the hosting page and pass the properties from a sqldatasource control. To this end I have a code like below;
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"SelectCommand="SELECT [1], [2], [3] FROM [table1]"></asp:SqlDataSource>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" DataMember="DefaultView" >
<ItemTemplate>
<uc:kk ID="kk1" runat="server" One='<%# Eval("1") %>' Two='<%# Eval("2") %>' Three='<%# Eval("3") %>' /></ItemTemplate></asp:DataList> I don't get any errors when I run the page, however it won't work as I wish. Only thing that appears in the rows of datalist is "01.01.0001 00:00:00".
View 4 Replies
View Related
Feb 20, 2007
is there a way that I can use the sqldatasource with a form view where my sqldatasource select statement is like this
select * from tblUsers where vcUserName=@vcUserName
<selectparameters>
<asp:Parameter Name="user.identity.name" Type="String />
</selectParameters>
View 1 Replies
View Related
Jan 5, 2006
After some help from the folks in the Security forum, I have some of the answer I need. Hopefully someone here can help me figure out the best method of using that information to find a final solution.
To start, here's a brief synapsis: I'm developing an App in ASP.NET 2.0, using forms-based authentication and the Login Control. I am able to login fine as far as I can tell, since I am able to proceed to the destinationURL without error. From there, I button click to the application in question. Here is where I have the problem.
I want to run a select query on a SQL table where a field = the current user's Username. I cannot find any examples of doing this. I have managed to figure out how to retrieve the current user's username via the Membership.GetUser method, but I can't seem to figure out how to apply that to my SqlDataSource Control and get a valid response.
a snippet of my control's code follows:
<script runat="server"> - This is run inline, not code-behindProtected memUser As MembershipUser
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)memUser = Membership.GetUser()End Sub</script>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SWGToolsetConnectionString %>"SelectCommand="SELECT [CharacterName] FROM [Characters] WHERE ([UserID] = '<% =Server.HtmlEncode(memUser.Username) %>')"></asp:SqlDataSource>
If anyone can tell me what I can or should be doing differently, I would appreciate it.
View 4 Replies
View Related
Jul 11, 2006
I am running into an issue trying to declaratively set up a SqlDataSource. I want to be able to filter some of my queries based on the user that is currently logged into the web site. I want to do it Declaratively as that's one of my favorite 2.0 features.Is there any way to do this with the Membership information? I know I can use the code behind to set the parameter, or store the User Name in Session Variable, and use a <asp:SessionParameter> but I think there should be a way to bind directly to the Membership user...Am I missing another option, or is there no built in way to do this? Any other suggestions...Thanks
View 1 Replies
View Related
Apr 18, 2007
I have a create user wizard. On the created user event. I am calling a datasource.insert to insert the email, userid, and opt in to newsletter option into another table.
For some reason it is inserting the value twice into the database. I have checked possibilities for why this might be happening. I am pulling my hair out.
Any ideas?
Andrew
View 7 Replies
View Related
Apr 21, 2007
Hi,How do I get hold of the HttpContext.Current.User.Identity.Name from within an sqldatasource? I want to create a WHERE clause that says WHERE UserName = @UserName and the @UserName parameter be filled with the current user name. I would be able to do this in code, but I don't know how to get at this information from within a datasource. At a guess I tried to use the Cookie option from the drop down list, and use the name of the FormsAuthentication Cookie, but this didn't work. Is there a way I can do this? If so how? I don't want to resort to using a hidden field or anything like that if I can help it. Many thanks, Steve
View 2 Replies
View Related
Jun 1, 2008
Just downloaded and installed the VS 2008 Express and created/tested some websites. I have done several aspx websites using VS 2005 during the last 2 years. Still I don't quite understand the details of coding the database connection and DataBing. For example, what does 'providerName',and Integrated Security really mean?Why in the Web.config file these are providerName="System.Data.SqlClient" and Integrated Security=True? Why in Default.aspxthere are both ntegrated Security=True;and USER ID=WEB; Password=webwebweb1". I know these may deal with the authentication mode of my SQL Serverdatabase.For the VS 2008 Express and SQL Server 2005 Express, I installed in my XP home PC, I used the file system websites, If I upgrade to XP Pro and install IIS web server, and use SQL Server 2005, what might be different? Jeffrey Web.config <connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=D5MRY6G1SQLExpress;Initial Catalog=Northwind;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>Default.aspx <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=D5MRY6G1SQLExpress;Initial Catalog=Northwind;Integrated Security=True; USER ID=WEB; Password=webwebweb1" ProviderName="<%$ ConnectionStrings:NorthwindConnectionString.ProviderName %>"MasterDetail.aspx <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
View 1 Replies
View Related
Jul 23, 2007
What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.
View 7 Replies
View Related
Dec 7, 2006
This is my first time to deploy an asp.net2 web site. Everything is working fine on my local computer but when i published the web site on a remote computer i get the error "Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed" (only in pages that try to access the database)
Help pleaseee
View 3 Replies
View Related
Mar 8, 2007
i am using visual web developer 2005 with SQL Express 2005 with VB as the code behindi have one database and three tables in itfor manipulating each table i am using separate SqlDataSource() is it sufficient to use one SqlDataSource() for manipulating all the three tables ? i am manipulating all the tables in the same page only please help me
View 1 Replies
View Related
Jun 2, 2004
Hello, everyone:
Does any one know the good T-SQL practice topic web site? It is better to include solutions. Thanks a lot.
ZYT
View 2 Replies
View Related
Sep 3, 2006
When setting up databases for end users, what's the best practice regarding who's the dbo for each individual database - the user itself or a sysadmin?
Does it really have any importance at all who the owner (as defined by 'dbo') is ?
View 5 Replies
View Related
May 7, 2007
(Terms)
TermID, Term
1----- Abc
2----- Arcico
3----- Tunic
and
(RelatedTerms)
TermID, RelatedTermID
1 ------ 3
1------ 2
2------ 4
I want to get the following results
1.- a list of all the terms that start with A%
2.- a list of all the related terms … that belong to terms that start with A%
For number 1 - I am doing a select on Terms table with where term like A%.
For number 2 – I am joining both tables and then once again doing a where term like A%.
Would it be more efficient to take the first results and put them in a table variable, and then just do a join with the second table RelatedTerms.TermID = Terms .TermID
The number of records that generally comeback are between 500 to 1000 records that
What would you consider is a better approach ? or maybe there is an even better way ?
View 4 Replies
View Related
Aug 14, 2007
Wasn't sure where to ask this question.
Was wondering what everyone is doing in regards to server/db protection?
Do you run your DB's on independent servers?
Do you run your DB's on clustered servers?
Do you run your DB's on redundant haardware w/ a 3rd party
application for bit-to-bit data replication?
Is anyone placing the DB's on a SAN's?
We're at a crossroads, and looking for a good direction to ensure the DB's are up.
Any insight welcome.
Thanks,
Kerry
View 3 Replies
View Related
Dec 11, 2007
hello
i'm a newbie for sql , but i want to learn sql on my own , is there any way that i can learn sql , do i have to download sample database from the internet, do i need to have my own server to play with. Hopefully someone show some lights on this.
regards
sutha
View 2 Replies
View Related
Apr 10, 2006
Please point me to a web resource from where I can study:1) writing complex queries such as those involving HAVING, mult-levelnested queries, GROUP BY, T-SQL functions2) Joins - a lot of practice3) Stored Procedures, transactions, cursors and triggers - I need someheavy-duty practiceWhere can I get some good practice of the above? Also, please recommenda good SQL Server/T-SQL book in the light of the above requirement.
View 3 Replies
View Related
Jan 11, 2006
Folks - had a look around Google and no surprises, but never found what i was looking for.
I want to see a real work best practice C# Stored Procedure for Sql 2005 (express is what i am using, but don't mind the Sql edition).
Almost everything i see is a "select * from table" which to be honest was my first stored proc many years ago - everything since has been fairly detailed.
I ask as i am sceptical, after years of trying to STOP building Sql queries in code (as it's hellish!) that the CLR technique really makes any kind of a diffence.
If someone has found that it HAS i'd love to hear about it. The thought of:
SqlCommand cmd = new SqlCommand ( "My Whole Stored Proc as Text" );
... doesn't appeal, never mind the potential for debugging syntactical issues and so on.
I was excited by this, until it became something i had to do in a real situation and then i got a little worried. Should i be?
View 7 Replies
View Related
Nov 2, 2006
create a table and name it Salary Information. Add an Employee Name and Salary column to the table. Create a column in the Employee table and name it Salary. Create a trigger that updates the Salary table with the employees's name and salary each time u insert data into the Salary column of the Employee table.
I tried but it didnt work!
Pls, help me!
View 4 Replies
View Related
Mar 12, 2008
Hi, my database is growing over 1Gb, and I only have one .mdf to keep them all. Should I use a secondary data file for my data? Can I do that now? Thanks.
View 5 Replies
View Related
May 22, 2008
Hi,
Please give the T-SQL script for this ? Thanks
Shanth
View 4 Replies
View Related
Jan 24, 2007
Good Morning,
I work for a company that has sees alot of people come and go. The one thing I have noticed is that people use their admin accounts to log into SQL and create sp, views and databases.When the user leaves I am stuck with all these objects that are owned by somone no longer working for the company.
So my question to you guys is: What is the best practice to use in creating new objects?
Thanks for your guru-ness!
View 3 Replies
View Related