ADO.NET :: Difference Between Sqlhelper.ExecuteReader And Sqlhelper.ExecuteXmlReader?
Dec 24, 2010what is the exact difference between Sqlhelper.ExecuteReader and Sqlhelper.ExecuteXmlReaderand which on is faster
View 3 Replieswhat is the exact difference between Sqlhelper.ExecuteReader and Sqlhelper.ExecuteXmlReaderand which on is faster
View 3 RepliesNote: You may not need to read the whole thing to know what's wrong... skip down to the part about the 3 scenarios if you'd like. Only read the begin if you'd like some background info on how I've tried implementing this and where the errors occurred.To begin with, I'm trying to retrieve a list of Clients stored in the CRM_Clients table for a given callerId.I retrieve the clients from my Controller with the SelectLiveClientsForCaller method. The message is then passed on to the DAL through the static Instance method in the DataProvider class:
public List<Client> SelectLiveClientsForCaller(int callerID)
{
List<Client> results = new List<Client>();
[code]...
what is the use of this...?
View 4 RepliesI have create a class SqlHelper in window console client project, then test it it works fine. In my SqlHelper class I make all methods are public static. Then I created an assembly, add it to my unit testing project. Whne I try to access the public function of SqlHelper class, I got error like "Error 1 'CreateDatabase.SqlHelper' is inaccessible due to its protection level ".
Here is my class:
[Code]....
at this line: SqlHelper.setUpTestDatabase I got above error, Where goes wrong?
string connectionString = (string)
ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("INSERT_PERSON",connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@Name",SqlDbType.NVarChar,50));
command.Parameters["@Name"].Value = txtName.Text;
command.Parameters.Add(new SqlParameter("@Age",SqlDbType.NVarChar,10));
command.Parameters["@Age"].Value = txtAge.Text;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
Above is my code.
I has more than 100 methods like this, so every time i'm opening the connection and close it, this will take too much of time, what i think is instead of this i would like to create the class for Connection open, that class will check whether the connection is closed or Broken then Open it(like SqlHelper.cs) so without big change on my methods, how to create that class and how to access that class from my methods.
I hired some to write a ecommerce website for me.and the used SqlHelper.GetInstance().ExecuteDataSet stuff i'm not familiar with.
But is real slow .
Screenshot of trace,page takes like +20 sec to return like 20 records of 3 field each!The DB queries are good, use same SP on my own app and it takes les then 1 sec.Did they use the sqlhelper wrong? is sql helper that slow?
It looks that the old SqlHelper class from the Microsoft Enterprise Library has been mostly replaced by the Database class which is included in the new Enterprise Library version 5.
I have a very simple and trivial example:
using Microsoft.ApplicationBlocks.Data;
private void PopulateCheckBoxGroup()
{
const string strConnTxt = "Server=(local);Database=DataBindTests;Integrated Security=True;";
const string strlSql = "select Technology from PreferredTechnology where ParentId = 1";
CheckBoxList1.DataSource = SqlHelper.ExecuteReader(strConnTxt, CommandType.Text, strlSql);
CheckBoxList1.DataTextField = "Technology";
CheckBoxList1.DataBind();
}
What is the difference between ExecuteDataSet and ExecuteReader.
View 2 Replieswhen i am executing xmlreader in enterprise library 4.1, iam getting an error like below
error: Invalid command sent to ExecuteXmlReader. The command must return an Xml result.
my code:
SqlDatabase
db = (
cmd = db.GetSqlStringCommand(
xmlReader = db.ExecuteXmlReader(cmd);
db = null;DbCommand cmd =
null;XmlReader xmlReader =
null;SqlDatabase)DatabaseFactory.CreateDatabase();"select
* from emp");DataSet ds = db.ExecuteDataSet(cmd);
I am trying to complete my function below but got lost in the different methods out there. It will always return 1 row and I need to get the values of the record and ADD into a new row. The function returns a DataTable.
[Code]....
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd;
[code]...
I am getting error that ExecuteReader: Connection property has not been initialized
I'm using data access block [URL] in asp.net 3.5. Back end is sql server 2005. It's working fine and returns result instantly for all DB calls. But, I've a problem with one SP. When I call it, executereader is taking too much time. In few cases, it is executed. And sometimes I get the Time out error. I run the same SP in sql server. It returns 9000 rows in 3 seconds.
View 3 RepliesDim reader As SqlDataReader
reader = cmd.ExecuteReader
Dim XML As String = reader("records").ToString
I've executed the command in SQL server and I get a result string with length of 54781But when I execute it via .NET and assign it to the XML variable, the length of XML is always 2033...so now Im thinking that the result column "records" cannot exceed this length for some reason...
here my code-
using (SqlDataReader sqlDataReader = ExecuteReader(CommandType.StoredProcedure, StoredProcedures.AuthenticateUser, sqlParameter))
{
isAuthenticated = Convert.ToBoolean(sqlParameter[2].Value);
if (isAuthenticated)
{
if (sqlDataReader.Read())
{
User = new UserEntity();
DbHelper.GetEntity(sqlDataReader, User);
}
}
}
I always get isAuthenticated as false because sqlParameter[2].Value is null all the time but when I execute my query with ExecuteNonQuery it gives me the value but in that case I can not fill the entity.
After trying many solutions listed on the internet I am very confused now. I have a C#/SQL web application for which I am simply trying to bind an ExecuteReader command to a Dropdownlist so the user can select a value. This is a VS2008 project on an XP OS.
How it works is after the user selects a table, I use this selection as an input parameter to a method from my Datamatch.aspx.cs file. Then this Datamatch.aspx.cs file calls a method from my ADONET.cs class file. Finally this method executes a SQL procedure to return the list of columns from that table. (These are all tables in Adventureworks DB). I know that this method returns successfully the list of columns if I execute this SP in SSMS. However, I'm not sure how to tell if it works in VS or not.This should be simple. How can I do this? Here is some of my code. The T-sQL stored proc:
CREATE PROCEDURE [dbo].[getColumnNames]
@TableName VarChar(50) AS
BEGIN
SET NOCOUNT ON;
[code]...
The CreateLabels method above correctly shows me the labels. But the CreateDropDownLists method just shows me one dropdownlist with nothing in it. In other words, it is not selectable. So how can I verify that the datareader is returning all 4 columns and inspect their values? I was able to find from datareader "COLUMN_NAME" but I don't know what properties to search to verify the column names.
I am having problems with the following. On debugging I find that when strKeywords = '', reader = "System.Data.SqlClient.SqlDataReader". However, as soon as strKeywords takes the value of anything else, reader = nothing. But the stored procedure handles the arguments fine, so I am very confused!
[Code]....
Some time i getting error below ,but i am did'nt used excutereader
ExecuteReader requires an open and available Connection. The connection's current state is closed.
This my code,
try { if (con.State != ConnectionState.Open) con.Open(); string result;
string Queryip = "ViewIp"; SqlCommand cmdip = new SqlCommand("ViewTranscation", con);
cmdip.CommandType = CommandType.StoredProcedure; cmdip.Parameters.AddWithValue("@QueryType", Queryip); cmdip.Parameters.AddWithValue("@Input1", "");
[Code] ....
Im trying to take the example from this website http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-2008-proximity-search-with-th and make it work on my site. Its this part im having troubles with
[Code]...
here is my code from my function that doesnt work.
[Code]...
Any suggestions on how to get it to work? it fails at rdr = cmd.ExecuteReader(); im also worried it will also fail at ZipCodes.Add(rdr["h.*"].ToString());
I would like to know about the difference between .DLL and .EXE?
View 1 RepliesI thought that <%: had replaced <%=, since mentions on [URL]Prior to ASP.NET 4, the <%= %> syntax was used to execute code and write it out to the page. Starting with ASP.NET 4, you should always use the <%: %> syntax instead..."
However, I've noticed that
<img src='<%=ResolveUrl("~/Images/MyImage.jpg")%>' alt="blah">
works, whereas
<img src='<%: ResolveUrl("~/images/MyImage.jpg")%>' alt="blah">
doesn't.
I'm not sure what the name for these types of expressions are so I've had trouble googling it.
what is the difference between the 1.0,2.0 and 3.5
View 6 RepliesWhat is the difference between L2S (Linq to SQL) and EF (Entity Framework), much appreciated if you highlight the cons and pros?
View 6 RepliesPossible Duplicate:
ASP.NET “special” tags
I hope this isn't too much of a newbie question. I seem to always use the correct syntax, but I don't really understand why I'm using the <%: and <%= in ASP.NET, and I was hoping someone could clarify for me. I found this article which explains <%= and <%#, but wasn't able to find anything in Google on <%:.
Examples of where I have used the various syntax:
<div>
<%: Html.LabelFor(model => model.Type) %>
<%: Html.TextBoxFor(model => model.Type)%>
</div>
and
<div id="header-menu">
<ul>
<li><%= Html.ActionLink("Home", "", "Home" )%></li>
</ul>
</div>
Possible Answer (per ChrisF): ASP.NET "special" tags
Are asp and c# completely different things or ..?
Is asp a language or asp.net? Are c, c++, c# languages?
What is a framework, stack, language
What is the difference between c#.net and vb.net ?
I faced this question in an interview. Any technical difference is there ? I heard that there are two methods additional in vb.net which are not there in vb.net.