|
Hi
i dont know when use a static method and when a non-static method in the data access layer
suppose we have
#1
public class Customer
{
.
.
.
publuc static DataSet GetCustomerList( int shopID )
{
//Do something and return a dataset
}
.
.
.
}
#2
public class Customer
{
.
.
.
publuc DataSet GetCustomerList( int shopID )
{
//Do something and return a dataset
}
.
.
.
}
#1 or #2 This is the problem
|
|
|
|
|
WDI wrote: i dont know when use a static method and when a non-static method in the data access layer
You didn't say what you want to do with the data access layer.
If you use static methods then everything in the applicatio will route through the static methods which will be using the same set of static fields in the class. If your application is single threaded then you probably don't have anything to worry about. If your application is multi-threaded (e.g. An ASP.NET application - all the sessions are running in the same application) then static methods will be a bottleneck because you'll only be able to allow one query to run at a time.
Does this help?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
OOOOOPS!
Is asp.net application multi threaded????????????
|
|
|
|
|
Yes. How did you think it can handle multiple requests simulataneously?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Is any way to build a table base on xml/xsd. Is any way to build xsd from xml. also xsd has some limitation like lentgh of string field.
Any idea ?
So Thanks
|
|
|
|
|
After opening a new xml file write:
<?xml version="1.0" standalone="yes"?>
<Users xmlns="http://www.yourwebsite.net/xmlfilename.xsd" >
<User><!--table name for each record-->
<ID></ID><!--field name-->
<name></name>
<age></age>
</User>
</Users>
Then from XML menu select CreateSchema to create xsd file,
To determine the Key field right click the element in the xml schema,Add,NewKey.
In code-behind page:
void GetUserData(string userID)
{
DataSet ds=new DataSet();
string strpath=Server.MapPath(Request.ApplicationPath);
ds.ReadXmlSchema(strpath+"\\xmlfilename.xsd");
ds.ReadXml(strpath+"\\xmlfilename.xml");
DataRow dr=ds.Tables["User"].Rows.Find(userID);
string username=dr["UserName"].ToString();
}
void SetUserData(string userID)
{
string strpath=Server.MapPath(Request.ApplicationPath);
DataSet ds=new DataSet();
ds.ReadXml("xmlfilename.xml");
DataRow dr=ds.Tables["User"].Rows.Find(userID);
dr["UserName"]="user1name";
ds.WriteXml(strpath+"\\xmlfilename.xml")
}
I am too late but i will never give up
|
|
|
|
|
So Thanks
I have three question. can I build select,insert,update and create table query from xml. how can I Create Schema without visual studio and what about relational database.
thanks
|
|
|
|
|
Sorry .. i didnt try any one from your clever ideas before...I think you should put your question as a new thread.
I hope one of the forum professional answer your question.
I am too late but i will never give up
|
|
|
|
|
Hi..
I have used Full-Text Search in a stored procedure with English words whithout any problems..But when i use it with Arabic words it gives me THE Error:
Server: Msg 7619, Level 16, State 1, Procedure SearchProject, Line 19
Execution of a full-text operation failed. A clause of the query contained only ignored words.
The stored procedure :
CREATE PROCEDURE SearchProject
(
@SearchString nvarchar(500),
@CultureName nvarchar(50),
@HowManyResults int OUTPUT
)
AS
CREATE TABLE #SearchTable
(
FieldNO int,
ProjectNO int,
ProjectName nvarchar(200),
ProjectDescription nvarchar(1000),
ProjectImage nvarchar(1000),
CultureID int
)
INSERT INTO #SearchTable (FieldNO,ProjectNO,ProjectName,ProjectDescription,ProjectImage,CultureID)
SELECT P.FieldNO, PL.ProjectNO,PL.ProjectName,PL.ProjectDescription,P.ProjectImage,PL.CultureID
FROM FREETEXTTABLE(Project_Locale,*,@SearchString) AS FT JOIN Project_Locale AS PL ON FT.[KEY]=PL.ProjectCultureID
JOIN Project AS P ON P.ProjectNO=PL.ProjectNO
WHERE PL.CultureID=dbo.GetCultureID(@CultureName)
INSERT INTO #SearchTable (FieldNO,ProjectNO,ProjectName,ProjectDescription,ProjectImage,CultureID)
SELECT P.FieldNO, PL.ProjectNO,PL.ProjectName,PL.ProjectDescription,P.ProjectImage,PL.CultureID
FROM Project_Locale AS PL ,Project AS P,
ProjectField_Locale AS FL,
FREETEXTTABLE(ProjectField_Locale,*,@SearchString) AS FT2
WHERE FL.FieldNO=P.FieldNO
AND FL.FieldCultureID=FT2.[KEY]
AND PL.ProjectNO=P.ProjectNO
AND PL.CultureID=dbo.GetCultureID(@CultureName)
AND FL.CultureID=dbo.GetCultureID(@CultureName)
INSERT INTO #SearchTable (FieldNO,ProjectNO,ProjectName,ProjectDescription,ProjectImage,CultureID)
SELECT P.FieldNO, PL.ProjectNO,PL.ProjectName,PL.ProjectDescription,P.ProjectImage,PL.CultureID
FROM Project_Locale AS PL ,Project AS P,
Feature_Locale AS PFEA,
ProjectFeature AS FP,
Feature AS F,
FREETEXTTABLE(Feature_Locale,*,@SearchString) AS FT3
WHERE FT3.[KEY]=PFEA.FeatureCultureID
AND FP.ProjectNO=P.ProjectNO
AND FP.FeatureNO=PFEA.FeatureNO
AND PL.ProjectNO=P.ProjectNO
AND F.FeatureNO=PFEA.FeatureNO
AND PFEA.CultureID=dbo.GetCultureID(@CultureName)
AND PL.CultureID=dbo.GetCultureID(@CultureName)
SELECT @HowManyResults=COUNT(DISTINCT ProjectNO) FROM #SearchTable
SELECT DISTINCT * FROM #SearchTable
RETURN
GO
I called the stored procedure using the following(in the Query Analayzer) :
USE nabeel1eagle
DECLARE @HowManyResults int
EXEC SearchProject 'ملفات','ar-SA',@HowManyResults OUTPUT
but when I use the previous code directly(without calling the stored procedure using EXEC) in the Query Analyzer it works fine.Like the following (part of the code)code:
SELECT P.FieldNO, PL.ProjectNO,PL.ProjectName,PL.ProjectDescription,P.ProjectImage,PL.CultureID
FROM FREETEXTTABLE(Project_Locale,*,'ملفات') AS FT JOIN Project_Locale AS PL ON FT.[KEY]=PL.ProjectCultureID
JOIN Project AS P ON P.ProjectNO=PL.ProjectNO
WHERE PL.CultureID=dbo.GetCultureID('ar-SA')
Could any one help and tell me how to solve this problem?
|
|
|
|
|
I am building software for controlling test stands with Borland C++ Builder 2006. This program uses a database. I like to create a new database during runtime with SQL-commands.
How can I realize this?
|
|
|
|
|
hi all i would like to know how to insert an image in a column which data type is binary and also how to retrieve such data
thank u all for ur help and support
abdelhameed81
|
|
|
|
|
|
well actualy i don't know how to do it with this binary or whatever but i did it by creating a column as text
i affected the root of the image in this field then i do some codes in vb.net
& it works
try to be good if you can't be the best
|
|
|
|
|
We are using .net application with oracle 9i database,we are trying to run a join query through our application but we are getting Server Application Unavailable error after the program runs for 5 minutes. we are using Windows 2003 operating system.how to increase the query performance through .net application.
There are three queries that run the aspx (output is a report in aspx). The first query returns between 9 - 18 records and is displayed horizontally.
The second query returns around 150 records. The third query returns one record for the combination of first and second query.
Thanks
|
|
|
|
|
Have you put a break point in your code, or trace statements to verify what is taking the time? If it is the database queries (when you get the data through the DataAdapter or DataReader) then the problem is likely with your database. How long does it take to run these queries through Oracle's tools?
If it takes a long time to run the queries then consider adding indexes. The columns specified in the where clause and the join are generally good candidates. If Oracle has a query profiler to assist in index tuning you might want to use that to see where the bottlenecks in the query are.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
HI EVERY BODY I'VE A PROBLEM IN MY CONNECTION TO SQLSERVER DATABASE THE ERROR I GOT IS
Device activation error the physical file name is incorrect
|
|
|
|
|
Possibly because some other application has the files open when SQL Server tries to "activate" the files. For example, Windows indexing tools like Windows Desktop Search or Google Desktop. Try shutting these down and retrying your operation.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
So I got 2 classes one I wrote to interrogate databases using normal ADO:
Mine:
<br />
SqlConnection myConnection = new SqlConnection(m_sConnectionString);<br />
<br />
SqlCommand myCommand = new SqlCommand(sQuery, myConnection);<br />
myCommand.CommandTimeout = 120;
<br />
myConnection.Open();<br />
<br />
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);<br />
<br />
<br />
return result;<br />
Microsoft Way
<br />
SqlDatabase dbSvc = new SqlDatabase(m_sConnectionString);<br />
<br />
DbCommand dbCommand = dbSvc.GetSqlStringCommand(sQuery);<br />
<br />
return ((SqlDataReader)dbSvc.ExecuteReader(dbCommand));<br />
What's faster?
My way:
<br />
SqlConnection myConnection = new SqlConnection(m_sConnectionString);<br />
<br />
SqlCommand myCommand = new SqlCommand(sQuery, myConnection);<br />
myCommand.CommandTimeout = 120;
<br />
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);<br />
<br />
DataTable myTable = new DataTable();<br />
myAdapter.Fill(myTable);<br />
<br />
myConnection.Close();<br />
myConnection.Dispose();<br />
myConnection = null;<br />
<br />
return (myTable);<br />
Microsoft Way:
<br />
SqlDatabase dbSvc = new SqlDatabase(m_sConnectionString);<br />
<br />
DbCommand dbCommand = dbSvc.GetSqlStringCommand(sQuery);<br />
<br />
DataTable dtData = null;<br />
DataSet dsData = dbSvc.ExecuteDataSet(dbCommand);<br />
<br />
dtData = dsData.Tables[0];<br />
<br />
return (dtData);<br />
Comments? Ideas?
Al
My eMail control
My Blog
|
|
|
|
|
|
When doing performance tests it is often very difficult to see small difierences on a single operation. I usually try several hundred iterations (accumulating the timing results with each iteration using a high precision timer class that calls QueryPerformanceCounter) and look at the average performance. This smoothes out minor jitter caused by the OS doing stuff, and usually gives a better measure, especially when the individual operation times are small.
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
Hi,
I have a ComboBox displays Status values which are three strings set at design-time. They are Active, Suspended, Disabled. Also I have a DataSet named dsUser which contains a DataTable named tblUser. tblUser has a DataColumn named Status. I navigate through the record in tblUser using a BindingNavigator and a BindingSource component which are automatically created for me by the designer. If I bind the SelectedItem property to tblUserBindingSource´s Status filed, everytime I move from one record to another fires OnColumnChanged event for the Status column. That makes DataRow modified although in fact, it is not modified so when I use dsUser.HasChanges(), it always returns true. How can I prevent this problem? On FormClosing event, I want to ask the user to save changes if tblUser is modified but this wrong firing makes it always modified wrongly. Please help!!!!!!!!!
|
|
|
|
|
Not sure if I have the right forum but really stuck and in need of help.
Problem: I have an SQL Server Table containing records. I load these records into a recordset. I then create a DBF Table. After creation I now want to load the SQL Records into the newly created DBF table. Simple enough but I keep getting errors. Here is my code:
<br />
'Create Table<br />
cnn.Open( _<br />
"Provider=Microsoft.Jet.OLEDB.4.0;" & _<br />
"Data Source=C:\;" & _<br />
"Extended Properties=dBase III;")<br />
<br />
strSQL = "CREATE TABLE Test" & _<br />
"(ID Text(50),")<br />
<br />
'Create Connection<br />
conn2 = CreateObject("ADODB.Connection")<br />
conn2.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & _<br />
"Data Source=" & Path & ";" & _<br />
"Extended Properties=""DBASE III;"";")<br />
-<br />
-<br />
rs2 = conn2.Execute("SELECT * FROM Test")<br />
<br />
' Create Connection To SQL<br />
-<br />
-<br />
rss2.OpenRecordSet("SELECT * FROM SQL_Table")<br />
<br />
'Portion that gives a problem.<br />
<br />
While Not rss2.EOF<br />
rs2.AddNew()<br />
rs2.Fields("ID").Value = rss2!ID<br />
rs2.Update()<br />
rss2.MoveNext()<br />
End While<br />
<-/code><br />
<br />
All of the connections work. The table is created. Now I have a problem transferring the recordsets from the SQL Recordset to the DBF. An error says: "Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."<br />
<br />
Any way to fix this using the existing code? Any help is REALLY appreciated. Thanks in advance.
|
|
|
|
|
OpenRecordSet has some additional parameters for type, options,etc. Not sure what the defaults might be for DBASE provider,(access would be forwardonly, readonly) but you might not have a recordset that supports updates. This is particularly likely with a recordset opened with Connection.Execute().
Try opening a recordeset on the DBASE table by createing a new Recordset object, opening it with
Rsnew.Open("select * from Test", conn2, adOpenDynamic,adLockOptimistic,adCmdText)
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
That would make sense. I tried the code you supplied, but had an error, those three objects are not declared. I assume I need to add a reference. I am using Visual Studios 2005. Any idea which reference it is? Or how to declare "adOpenDynamic,adLockOptimistic,adCmdText" ? - Thanks again.
|
|
|
|
|
If you are using .Net, you should use System.Data.OleDb class, rather than the "old" ado stuff.
I suspect you must have added a reference to msado.dll in order to get the Ado classes, probably need some of the other dlls to get the enumerations exposed( or they're there but need the enumeration prefix - CursorType.adDynamic, etc.)
Use SqlClient classes for SQL Server, they're much faster than the OleDb (although you can use either for SQL, just a bit more overhead in the oleDb.
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|