Вы находитесь на странице: 1из 21

ADO.NET 2.

0 Interview Questions and


Answers
This page contains the collection of ADO.NET 2.0 Interview Questions and Answers /
Frequently Asked Questions (FAQs) under category Microsoft .NET Technologies. These
questions are collected from various resources like informative websites, forums, blogs,
discussion boards including MSDN and Wikipedia. These listed questions can surely help in
preparing for ADO.NET 2.0 interview or job.

Explain How to create dynamic Gridview?


Many times we have the requirement where we have to create columns dynamically. This article
describes you about the dynamic loading of data using the Data Table as the data source. Details
of the Grid Let?s have a look at the code to understand better. Create a gridview in the page,
Drag and drop the GridView on to the page Or Manually type GridView definition in the page.
public partial class _Default : System.Web.UI.Page { #region constants const string NAME =
"NAME"; const string ID = "ID"; #endregion protected void Page_Load(object sender,
EventArgs e) { loadDynamicGrid(); } private void loadDynamicGrid() { #region Code for
preparing the DataTable //Create an instance of DataTable DataTable dt = new DataTable();
//Create an ID column for adding to the Datatable DataColumn dcol = new DataColumn(ID
,typeof(System.Int32)); dcol.AutoIncrement = true; dt.Columns.Add(dcol); //Create an ID
column for adding to the Datatable dcol = new DataColumn(NAME, typeof(System.String));
dt.Columns.Add(dcol); //Now add data for dynamic columns //As the first column is auto-
increment, we do not have to add any thing. //Let's add some data to the second column. for (int
nIndex = 0; nIndex < 10; nIndex++) { //Create a new row DataRow drow = dt.NewRow();
//Initialize the row data. drow[NAME] = "Row-" + Convert.ToString((nIndex + 1)); //Add the
row to the datatable. dt.Rows.Add(drow); } #endregion //Iterate through the columns of the
datatable to set the data bound field dynamically. foreach (DataColumn col in dt.Columns) {
//Declare the bound field and allocate memory for the bound field. BoundField bfield = new
BoundField(); //Initalize the DataField value. bfield.DataField = col.ColumnName; //Initialize
the HeaderText field value. bfield.HeaderText = col.ColumnName; //Add the newly created
bound field to the GridView. GrdDynamic.Columns.Add(bfield); } //Initialize the DataSource
GrdDynamic.DataSource = dt; //Bind the datatable with the GridView.
GrdDynamic.DataBind(); } }

Explain Which name space is used to get assembly details?


System.Assembly is the name space which u need to include in u r program to get the assembly
details.To get the assembly details of the current running one is thru reflection so u need another
namespace called System.Reflection "Happy Programming"

Explain How to pass multiple tables in datasets simultaneously?


sqldataadopter .fill(Ds,"tableName")
again create new sql dataadopetr and fill this ds with sceond name of table giving..
Explain the difference in an Abstract Class and an Interface?
An Abstract class has abstract methods. An Abtsract class can not be instanitiated directly. All the
abtract methods are implemented in the derived class. There is no multiple inheritance here.

Interface class also has abstract methods and all of them are public. You can have multiple
inheritance with Interfaces.

Feature Interface Abstract class


Multiple inheritance A class may inherit several interfaces. A class may inherit only one abstract
class.
Default implementation An interface cannot provide any code, just the signature. An abstract
class can provide complete, default code and/or just the details that have to be overridden.
Access Modfiers An interface cannot have access modifiers for the subs, functions, properties etc
everything is assumed as public An abstract class can contain access modifiers for the subs,
functions, properties
Core VS Peripheral Interfaces are used to define the peripheral abilities of a class. In other words
both Human and Vehicle can inherit from a IMovable interface. An abstract class defines the core
identity of a class and there it is used for objects of the same type.
Homogeneity If various implementations only share method signatures then it is better to use
Interfaces. If various implementations are of the same kind and use common behaviour or status
then abstract class is better to use.
Speed Requires more time to find the actual method in the corresponding classes. Fast
Adding functionality (Versioning) If we add a new method to an Interface then we have to track
down all the implementations of the interface and define implementation for the new method. If
we add a new method to an abstract class then we have the option of providing default
implementation and therefore all the existing code might work properly.
Fields and Constants No fields can be defined in interfaces An abstract class can have fields and
constrants defined

Explain How to bind the controls(best practice) comboboxes to the data in the dataset?
DropDownList1.DataSource=Myds;
DropDownList1.DataTextField = "FieldName";
DropDownList1.DataValueField = "FieldName";

How to identify the controls which can be used for binding data?
Control which drives from BaseDataBoundControl Class

Serves as the base class for controls that bind to data using an ASP.NET data source control.

Explain the Differences between OLEDB SQL SERVER, OLEDBDOTNET PROVIDER?


OleDBDotNet Provider can be used to connect to any DataSource but OleDb SQL SERVER can
be used to connect only to a SQL Server DataSource.

Explain the difference in Record set and Dataset?


Data Reader worked as conventional Record Set of VB but Data Set Can store a complete
database with all the relations and constraints.
Data Reader worked in Read only where as Data Set provide u the flexibility of Updating data
also.

Data Reader worked in connected mode only, whereas Data set works in disconnected mode
also.

Recordset is a collection of records returned by the query.

Dataset is merely a collection of tables.

Explain all the classes those are used for database connections between sql server and
asp.net?
1.SqlClientPermission - Enables the .NET Framework Data Provider for SQL Server to help
ensure that a user has a security level adequate to access a data source.

2.SqlClientPermissionAttribute - Associates a security action with a custom security attribute.

3. SqlCommand - Represents a Transact-SQL statement or stored procedure to execute against a


SQL Server database. This class cannot be inherited.

4.SqlCommandBuilder - Automatically generates single-table commands used to reconcile


changes made to a DataSet with the associated SQL Server database. This class cannot be
inherited.

5. SqlConnection - Represents an open connection to a SQL Server database. This class cannot
be inherited.

6.SqlDataAdapter - Represents a set of data commands and a database connection that are used
to fill the DataSet and update a SQL Server database. This class cannot be inherited.

7.SqlDataReader - Provides a means of reading a forward-only stream of rows from a SQL


Server database. This class cannot be inherited.

8.SqlError - Collects information relevant to a warning or error returned by SQL Server. This
class cannot be inherited.

9.SqlErrorCollection - Collects all errors generated by the .NET Framework Data Provider for
SQL Server. This class cannot be inherited.

10.SqlException - The exception that is thrown when SQL Server returns a warning or error.
This class cannot be inherited.

11.SqlInfoMessageEventArgs - Provides data for the InfoMessage event. This class cannot be
inherited.
12.SqlParameter - Represents a parameter to a SqlCommand, and optionally, its mapping to
DataSet columns. This class cannot be inherited.

13.SqlParameterCollection - Represents a collection of parameters relevant to a SqlCommand as


well as their respective mappings to columns in a DataSet. This class cannot be inherited.

14.SqlRowUpdatedEventArgs - Provides data for the RowUpdated event. This class cannot be
inherited.

15.SqlRowUpdatingEventArgs- Provides data for the RowUpdating event. This class cannot be
inherited.

16. SqlTransaction - Represents a Transact-SQL transaction to be made in a SQL Server


database. This class cannot be inherited.

What is difference between ado and ado.net?


ADO and ADO.NET are different in several ways:

ADO works with connected data. This means that when you access data, such as viewing and
updating data, it is real-time, with a connection being used all the time. This is barring, of course,
you programming special routines to pull all your data into temporary tables.

ADO.NET uses data in a disconnected fashion. When you access data, ADO.NET makes a copy
of the data using XML. ADO.NET only holds the connection open long enough to either pull
down the data or to make any requested updates. This makes ADO.NET efficient to use for Web
applications. It's also decent for desktop applications.

ADO has one main object that is used to reference data, called the Recordset object. This object
basically gives you a single table view of your data, although you can join tables to create a new
set of records. With ADO.NET, you have various objects that allow you to access data in various
ways. The DataSet object will actually allow you to store the relational model of your database.
This allows you to pull up customers and their orders, accessing/updating the data in each related
table individually.

ADO allows you to create client-side cursors only, whereas ADO.NET gives you the choice of
either using client-side or server-side cursors. In ADO.NET, classes actually handle the work of
cursors. This allows the developer to decide which is best. For Internet development, this is
crucial in creating efficient applications.

Whereas ADO allows you to persist records in XML format, ADO.NET allows you to
manipulate your data using XML as the primary means. This is nice when you are working with
other business applications and also helps when you are working with firewalls because data is
passed as HTML and XML.

How to identify the updated rows in a dataset?


If the RowState property of the DataRow is "Modified" then that DataRow can be treated as
updated.

If dr.RowState=DataRowState.Modified then
' u r logic here
End if

What is difference in Record set and Dataset?


Data Reader worked as conventional Record Set of VB but Data Set Can store a complete
database with all the relations and constraints.

Data Reader worked in Read only where as Data Set provide u the flexibility of Updating data
also.

Data Reader worked in connected mode only, whereas Data set works in disconnected mode
also.

Recordset is a collection of records returned by the query.

Dataset is merely a collection of tables.

How to add a check box or a dropdown list to a column in a datagrid?


By using template column, as

<asp:TemplateColumn>

<asp:ItemTemplate>

<asp:CheckBox></asp:CheckBox>

<asp:DropDownList></asp:DropDownList>

</asp:ItemTemplate>

</asp:TemplateColumn>

Explain Advantages of ADO.Net?


Ado.net uses dataset for accessing the data , since the dataset is created in client side there is no
need of connection at the time of working on dataset ,to the server(where the database is
present), so this makes the data accessing faster mainly in the net environment.

rs:
Ado.net uses dataset for accessing the data , since the dataset is created in client side there is no
need of connection at the time of working on dataset ,to the server(where the database is
present), so this makes the data accessing faster mainly in the net environment.
ADO.NET Interview Questions and Answers
This page contains the collection of ADO.NET Interview Questions and Answers / Frequently
Asked Questions (FAQs) under category Microsoft .NET Technologies. These questions are
collected from various resources like informative websites, forums, blogs, discussion boards
including MSDN and Wikipedia. These listed questions can surely help in preparing for
ADO.NET interview or job.

What is ADO.NET?
ADO.NET is a part of the Microsoft .NET Framework. This framework provides the set of
classes that deal with data communication between various layers of the software architecture
and the database. It provides a continuous access to different data source types such as SQL
Server versions 7, 2000, 2005. It also provides connectivity options to data sources through OLE
DB and XML. Connectivity may be established with other databases like Oracle, MySQL etc. as
well.

ADO.NET has the ability to separate data access mechanisms, data manipulation mechanisms
and data connectivity mechanisms.

ADO.NET introduces along with it the disconnected architecture. In a disconnected architecture,


data may be stored in a DataSet. It contains providers for connecting to databases, commands for
execution and retrieval of results.

The classes for ADO.NET are stored in the DLL System.Data.dll.

can we connect two dataadapters to same data source using single connection at same time?

yes,we can connect two dataadapters to same datasource using single connection at same time.
There is a technology in ado.net 2.0 called MARS usinng Mars in connection string we can do it.
for eg:
cn.ConnectionString = "server=(local); database=employee; integrated security=sspi;
MultipleActiveResultSets=True";

Can we do database operations without using any of the ADO.net objects?


No its not at all possible.

If we are not returning any records from the database, which method is to be used?
There is a method called Execute Non Query. This method executes the Update, Delete etc. This
does not return any rows but will give the number of rows affected.

how can i retrieve two tables of data at a time by using data reader?
Data reader read and forward only, how is it possible to get 2 tables of data at a time?
yes this is possible
If we execute 2 select command either in stored procedure or in select command and then
executereader method fired of command object. it return 2 tables in datareader.

like :
string str="Select * from a;select * from b";
cmd.commandtext=str;
dr=cmd.executereader();

Now it return 2 tables in datareader (dr).

Explain ExecuteNonQuery?
// Summary:

// Executes a Transact-SQL statement against the connection and returns the number of rows
affected.

// Returns:

// The number of rows affected.

What is the ExecuteScalar method?


// Summary:

Executes the query, and returns the first column of the first row in the result set returned by the
query. Additional columns or rows are ignored.

// Returns:

The first column of the first row in the result set, or a null reference (Nothing in Visual Basic) if
the result set is empty.

Which one of the following objects is a high-level abstraction of the Connection and
Command objects in ADO.NET?
DataReader DataSet DataTable DataView DataAdapter

Answer: DataAdapter

How can we load multiple tables in to Dataset?


DataSet ds=new DataSet();

SqlDataAdapter dap=new SqlDataAdapter(Select * from <tablename>,<connection1>);

dap.Fill(ds,"TableOne");

SqlDataAdapter dap1=new SqlDataAdapter(Select * from <tablename>,<connection1>);


dap1.Fill(ds,"tableTwo");

What is connection String?


connection String - a string which contains address of the database we want to connect to.

What is Delegate?
Delegate is an important element of C# and is extensively used in every type of .NET
application. A delegate is a class whose object (delegate object) can store a set of references to
methods.

How do you update a Dataset in ADO.Net and How do you update database through
Dataset?
a. Update a dataset;
Dataset ds = new dataset();
SqlDataAdapter adp = new SqlDataAdapter(Query,connection);
Adp.fill(ds);
Again you can add/update Dataset as below
SqlDataAdapter adp1 = new SqlDataAdapter(Query1,connection);
Adp1.fill(ds);

b. Update database through dataset.


SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(mySqlDataAdapter);
Foreach(datarow dr in ds.table[0].rows)
{
Dr[�column Name�] = �value�;
mySqlDataAdapter.Update(ds);
}

What are the steps to connect to a database?


1. Create a connection. This requires a connection string, which can be given declaratively or put
in a well defined place like the .config files. Advantage of keeping in .config files is that it
enables use of Connection Pooling by .Net framework, else even one small change in connection
string will cause CLR to think it's not the same connection and will instantiate new connection
for other request.

2. Open the connection and keep it open until done, typically done as using (con) { //use }

3. If using connected data model, create a SqlCommand object, decorate it with desired
command, command type (stored procedure for eg), add any parameters and their values to the
command, and then consume the command by using ExcuteReader or ExecuteScalar. In case of
ExecuteReader, we will get back a handle to a fast-forward, read only pointer to the recordset.
We can also decorate Command object with multiple recordsets in 2.0 and execute one by one
(MARS - Multiple Active Record Sets)

4. If using disconnected data model, create a DataAdapter object, decorate it with desired
SELECT, INSERT, UPDATE, DELETE commands, add parameters as necessary and then fill up
a DataSet or DataTable using the DataAdapter. Subsequent SQL can be executed using insert,
update, delete commands on the dataset.

How do you connect to SQL Server Database without using sqlclient?


you can connect sql using oledbname space .

What is Partial class?


A Partial class is a class that can be split into two or more classes. This means that a class can be
physically separated into other parts of the class within the same namespace. All the parts must
use the partial keyword. All the other classes should also have the same access modifier. At the
compile time, all the partial classes will be treated as a single class. Let us list some advantages
of having partial classes.

what are the advantages and disadvantages of using datalist?


Adv: the DataList's display is defined via templates,DataList allows for much more
customization of the rendered HTML markup , by which it is more user-friendly displays of data.

DisAdv:
adding such functionality with the DataList takes more development time than with the
DataGrid, as,

1. The Edit/Update/Cancel buttons that can be created in a DataGrid via the


EditCommandColumn column type, must be manually added to the DataList, and

2. The DataGrid BoundColumn column types automatically use a TextBox Web control for the
editing interface, whereas with the DataList you must explicitly specify the editing interface for
the item being edited via the EditItemTemplate.

3. we can't do the paging and sorting with datalist controls.

What is the difference between data reader and data adapter?


DateReader is an forward only and read only cursor type if you are accessing data through
DataRead it shows the data on the web form/control but you can not perform the paging feature
on that record(because it's forward only type). Reader is best fit to show the Data (where no need
to work on data)

DataAdapter is not only connect with the Databse(through Command object) it provide four
types of command (InsertCommand, UpdateCommand, DeleteCommand, SelectCommand), It
supports to the disconnected Architecture of .NET show we can populate the records to the
DataSet. where as Dataadapter is best fit to work on data.

What is the difference between data reader and data set?


1) DataSet is disconnected object type. It uses XML to store data.

2) It fetches all data from the data source at a time


3) Modifications can be updated to the actual database
4) It will reduce the application performance.

Does SQLClient and OLEdb class share the same functionality?


No, each have its own functionality,

ex : for sql client , there is SqlConnection object

and for oledb client , there is OleDBConnection

why edit is not possible in repeater?


It has no such feature.

Difference between SqlCommand and SqlCommandBuilder?


a) SQLCommand is used to execute all kind of SQL queries like DML(Insert, update,Delete) &
DDL like(Create table, drop table etc)
b)SQLCommandBuilder object is used to build & execute SQL (DML) queries like select, insert,
update & delete.

Why ca not we use Multiple inheritance and garbage collector paralelly in .net?
.net doesn't support the mutiple inheritance, perhaps you may talk about multi-level inheritance.

In the later case, if a class is inherited from another class, at the time of creating instance, it will
obviously give a call to its base class constructor (ie bottom - top approach). Like wise the
constructor execution is takes place in top down approach (ie. base class constructor is executed
and the derived class constructor is executed).

So for GC, it will collect only when an object does not have any reference. As we see previously,
the derived is constructed based on base class. There is a reference is set to be. Obviously GC
cannot be collected.

How to find the given query is optimised one or not?


First Excute Sql Quries in Query Analzer,see How much time 2 take Excute , if Less then the ur
desired Time, then it will Optimize query

How to copy the contents from one table to another table and how to delete the source table
in ado.net?
it is possible
DataSet ds;

sqlAdap.Fill(ds);

Datatable dt = ds.Tables[0].copy();

//now the structure and data are copied into 'dt'

ds.Tables.remove(ds.Table[0]);

//now the source is removed from the 'ds'

How to call the SQL commands asynchronously in ADO.NET version 2.0?


executescalar()
executereader()
executenonquery()

these comes with Begin and End like Beginexecutescalr() Endexecutescalar().......

by using these command we can achieve asynch comm in ado.net

what is typed and untyped dataset?


A DataSet can be Typed or Untyped. The difference between the two lies in the fact that a Typed
DataSet has a schema and an Untyped DataSet does not have one. It should be noted that the
Typed Datasets have more support in Visual studio.

I loaded the dataset with a table of 10 records. One of the records is deleted from the
backend, How do you check whether all the 10 records were present while updating the
data(Which event and steps) and throw the exception.
By Using the Transactions we can check the Exact Numbers of the rows to be updated and if the
updation fails then the Transaction will be rollbacked.

Can dataReader hold data from multiple tables?


data reader can hold data from multiple tables and datareader can hold more than one table.

string query="select * from employee; select * from student";

sqlcommand cmd=new sqlcommand(query, connection);

sqldatareader dr=cmd.executeReader();

if(dr.hasrows)
{

dr.read();

gridview1.DataSource=dr;

gridview1.Databind();

if(dr.nextresult)

gridview2.datasource=dr;

gridview2.databind();

dr.colse();

connection.close();

What is different between SqlCommand object and Command Behavior Object?


DO.NET Command Object - The Command object is similar to the old ADO command object.

It is used to store SQL statements that need to be executed against a data source.

The Command object can execute SELECT statements, INSERT, UPDATE, or DELETE
statements, stored procedures, or any other statement understood by the database.

what is bubbled event can u pls explain?


all heavy controls like grid view,datagrid or datalist,repeater controls cantains the chield controls
like button or link button, when we click this button then the event will be raised, that events are
handled by parant controls,that is called event bubbling,means event is bubbled from
bottom(chield)to up(parant).

If a table contains 20000 records . In a page at each time 100 records to be displayed.
What are the steps u will take to improve performance? will you use dataset or datareader?

we have to use a dataset because on using datareader forward only paging can be achieved.
Suppose if you are at 1000 page and you want to go back to 999th page, if you use datareader it
cannot be achieved, since it does not support backward navigation.
Dataset supports forward and backward navigation
What is data access layer?
Data Access layer is actually a part of Architecture layer. It has 2 tier,3 tier or N tier Layer.
Generally we use 3 tier Layer 1) Presentation layer,Business Logic layer and then Data Access
Layer. Data Access layer is a medium to talk between database and Business Logic layer.
It helps to maintain flexibility,resuablity and even secuity also. In security SQL Injection can be
stopped with 3 iter Archietcture.

What are the different row versions available in table?


There are four types of Rowversions.

Current:

The current values for the row. This row version does not exist for rows with a RowState of
Deleted.

Default :

The row the default version for the current DataRowState. For a DataRowState value of Added,

Modified or Current, the default version is Current. For a DataRowState of Deleted, the version
is Original.

For a DataRowState value of Detached, the version is Proposed.

Original:

The row contains its original values.

Proposed:

The proposed values for the row. This row version exists during an edit operation on a row, or for
a

row that is not part of a DataRowCollection.

What are the two fundamental objects in ADO.NET?


Datareader and Dataset are the two fundamental objects in ADO.NET

What we do with the object of ado.net dataset after using it?Can we dispose it or can we set
it nothing?Is it must or not?
we use dispose

What provider ADO.net use by default?


Ado.net uses no Dataprovider by default and this is absulotely correct answere. there is no other
choice for this question
What is the provider and namespaces being used to access oracle database?
The provider name is oledb and the namespace is system.data.oledb

Explain acid properties?


The term ACID conveys the role transactions play in mission-critical applications. Coined by
transaction processing pioneers, ACID stands for atomicity, consistency, isolation, and durability.

These properties ensure predictable behavior, reinforcing the role of transactions as all-or-none
propositions designed to reduce the management load when there are many variables.

What is Atomicity?
A transaction is a unit of work in which a series of operations occur between the BEGIN
TRANSACTION and END TRANSACTION statements of an application. A transaction
executes exactly once and is atomic ?
all the work is done or none of it is.
Operations associated with a transaction usually share a common intent and are interdependent.
By performing only a subset of these operations, the system could compromise the overall intent
of the
transaction. Atomicity eliminates the chance of processing a subset of operations.

What is Isolation?
A transaction is a unit of isolation ? allowing concurrent transactions to behave as though each
were the only transaction running in the system.

Isolation requires that each transaction appear to be the only transaction manipulating the data
store, even though other transactions may be running at the same time. A transaction should
never see the intermediate stages of another transaction.

Transactions attain the highest level of isolation when they are serializable. At this level, the
results obtained from a set of concurrent transactions are identical to the results obtained by
running each transaction serially.

Because a high degree of isolation can limit the number of concurrent transactions, some
applications reduce the isolation level in exchange for better throughput.

what is data Adapter?


Data adapter is bridge between Connection and DataSet , Data adapter in passing the sql query
and fill in dataset

How to find the count of records in a dataset?


DS.Tables["tabname"].Rows.Count;

we can get count of the records.


Datagrid or Gridview Interview Questions
and Answers
This page contains the collection of Datagrid or Gridview Interview Questions and Answers /
Frequently Asked Questions (FAQs) under category Microsoft .NET Technologies. These
questions are collected from various resources like informative websites, forums, blogs,
discussion boards including MSDN and Wikipedia. These listed questions can surely help in
preparing for Datagrid or Gridview interview or job.

What is a DataGrid or Grid View?


The DataGrid Web server control is a powerful tool for displaying information from a data
source. It is easy to use; you can display editable data in a professional-looking grid by setting
only a few properties. At the same time, the grid has a sophisticated object model that provides
you with great flexibility in how you display the data.

What is the difference between the System.Web.UI.WebControls.DataGrid and and


System.Windows.Forms.DataGrid?
The Web UI control does not inherently support master-detail data structures. As with other Web
server controls, it does not support two-way data binding. If you want to update data, you must
write code to do this yourself. You can only edit one row at a time. It does not inherently support
sorting, although it raises events you can handle in order to sort the grid contents. You can bind
the Web Forms DataGrid to any object that supports the IEnumerable interface. The Web Forms
DataGrid control supports paging. It is easy to customize the appearance and layout of the Web
Forms DataGrid control as compared to the Windows Forms one.

How do you check whether the row data has been changed?
The definitive way to determine whether a row has been dirtied is to handle the changed event
for the controls in a row. For example, if your grid row contains a TextBox control, you can
respond to the control�s TextChanged event. Similarly, for check boxes, you can respond to a
CheckedChanged event. In the handler for these events, you maintain a list of the rows to be
updated. Generally, the best strategy is to track the primary keys of the affected rows. For
example, you can maintain an ArrayList object that contains the primary keys of the rows to
update.

Why can not I edit the results of a query in the SQL Editor?
Query statements MUST return the ROWID to be updatable. For example:

select * from employee where salary > 2000

would not be updatable, whereas:

select employee.*, rowid from employee where salary > 2000


would be updatable.

To reduce this obvious nuisance, you can use the TOAD-specific EDIT statement. For example:

edit employee where salary > 2000

If the resultset should be editable but remains read-only, make sure the TOAD Options > Data
Grids - Data tab, Default to Read-Only Queries checkbox is NOT enabled

Why can not I add a new record by hitting the down arrow key in the data tab?
Please upgrade your copy of TOAD to at least version 7.4.0.3. This functionality has been
restored.

What is the OCI Buffer Array Size option for in the View - Options - Oracle - General
section?
After a SELECT query is executed, we must retrieve the rows from the Oracle server to your PC.
We do not retrieve the rows all at once, nor do we retrieve them one at a time (unless there is a
LONG or LOB column involved). We retrieve the rows in blocks. The number of rows retrieved
in each block is the number of rows you specify with "OCI Array Buffer Size". TOAD defaults
to 25 because SQL*Plus defaults to 25. In my opinion, an optimal setting is more like 500 or
1000. Here is why: If your dataset has 1,000 rows, and your OCI Array Buffer size is set to 25,
then TOAD has to make 40 (that's 1000 / 25) round trips across the network to retrieve all of the
rows. So you can immediately see why 500 or 1000 is better. The only disadvantage to a higher
setting of OCI Array Buffer Size is that TOAD must allocate memory to hold that many rows
prior to each fetch. If that many rows are actually fetched, there is no loss. On the other hand, if
not that many rows are retrieved, then we allocated some memory that is not going to be released
until the cursor is freed. Luckily, this is a trivial amout of memory, in the grand scheme of things.

What is the Clone Cursor Options for on the SaveAs dialogs in the Schema Browser and
(SQL) Editor?
When "Clone Cursor" is turned OFF, and a user goes to the "save as" screen and begins an
export, we use the actual cursor which is tied to the data grid. The advantage to this is that the
query does not need to be re-executed. The disadvantage to this is that the whole dataset must be
held in your PC's RAM, because this is a scrollable dataset (it is this mechanism that allows
scrolling in the grids). When "Clone Cursor" is turned ON, and a user goes to the "save as"
screen and begins an export, we create a new, non-scrollable cursor. The advantage here is that as
rows are read in and sent to the destination file, we don't have to hold them in memory any
longer...and a minimal amout of RAM is used. The disadvantage is that for this to happen, the
query must be re-executed. So...which setting should you use? If your query returns a LOT of
rows (too many to hold in your PC's RAM), you should have "Clone Cursor" turned ON...even if
your query takes a long time to execute. If your query returns a number of rows such that the
entire dataset will easily fit into your PC's memory, then we should consider the execution time
for the query. If execution time is slow, then leave "Clone Cursor" OFF. If execution time is fast,
then it doesn't really matter.
This option has been renamed to "Display all exported results in grid" for version 9.1. It will be
greyed out if the dataset being exported has already been completely fetched, e.g. OCI Array =
500 and only 125 records, or you have already scolled to the bottom of the result set. If either of
these cases are not true, then if this option IS set, Toad will execute the statement again and fetch
ALL of the rows for the export, and then also send the entire result set to the original data grid so
you can see them there too after the export has finished.

Explain My string data is all coming out as question marks?


We have found that this happens when the database character set is WE8ISO8859P1, and the
Oracle client is 9.2.0.1. This is an Oracle bug, and upgrading your client to 9.2.0.4 or higher
should resolve the problem. In any other case, please generate a TOAD Support Bundle from the
Help menu and let us know what you are seeing.

How do I delete a record?


Assuming that the result set is editable (i.e. you have written a query that includes the ROWID,
or you have used the TOAD Edit command), you can do one of the following:

*
"Delete row" button on the SQL Editor toolbar
*
CTRL+Del
*
Single Record View, Delete Button

How can I see the data in nested tables?


TOAD 7.5 and up can show nested table data in popups from the data grids if you are using an
8.0 or higher Oracle client. The nested table data will appear in the grid cell as "(DATASET)".
Right-click over this cell and choose "Popup editor". TOAD 9.0.1 now supports nested table data
in its "run as script" function. TOAD versions 7.4 and previous do not support nested table data
due to a limitation in their data layer.

How can I see nested object data?


TOAD 7.5 and up can show nested object type data in popups from the data grids if you are
using an 8.0 or higher Oracle client. Right-click on the cell that should contain the data and
choose "Popup editor". TOAD 9.0.1 now supports nested object data in its "run as script"
function. TOAD versions 7.4 and previous do not support nested object data due to a limitation
in their data layer.

How can I see TIMESTAMP and INTERVAL data?


TOAD 7.5 and up can show TIMESTAMP and INTERVAL data in its data grids if you are using
a 9.0.1 or higher Oracle client. TOAD 9.0.1 supports TIMESTAMP and INTERVAL data in its
"run as script" function. TOAD versions 7.4 and previous do not support TIMESTAMP and
INTERVAL data due to a limitation in their data layer.

To see timestamp/intervals in the "datatype" drop down in the Create/Alter Table window, and in
the "Add Column" window, go to options → datatypes, and make sure "Include
Timestamp/Interval Types" is checked.

Why can not I set a style in my XLS SaveAs exports of DataGrid data?
Try upgrading to the current release of TOAD, as we have obtained an updated XLS component.
If you are still experiencing the problem, you can do this: FORMAT → CELLS → NUMBER
TAB → change to Currency, Percentage, etc.

Why does saving to XLS instance not work sometimes?


From the Toad lists.

One of my co-workers experiences a very strange problem. When he is saving the results of a
query using "Save As" into Excel Instance nothing happens. There is 1 opened Excel and it stays
empty. All other "save as" option work fine (including saving into Xls File). What could be the
problem?

John Dorlon replied :

*
Close excel.
*
Look in task manager.
*
If you still see excel running, kill it.

It seems that Excel gets confused as to whether it is running once or not and the hidden instance
of Excel is causing the problem as it is most likely receiving the saved data. (explanation
courtesy of Norm and it might even be right! LOL)
How do I name the tabs when I run a script?

How do I name the tabs when I run a script?


When you run a script in the MOE using F5, the output of the script is displayed at the bottom of
the screen. Each command creates a separate tab for its results, as well as being included in the
main script output tab. These tabs are simply named 'Grid n' where n is an incrementing number
starting at 1. If you run a script with 5 SELECT statements, you get 'Grid 1' though 'Grid 5'.

A question on the list from Roger Simoneau, asked how we could programatically rename the
tabs from within the script. Both Erwin Rollauer and Ed Klinger (TeamT) supplied answers.

If you use the TTITLE directive before the SELECT statement, the tab will be named using the
data from the TTITLE directive, as follows :

TTITLE today
SELECT sysdate FROM dual;

The tab for this statement will have the title 'today' exactly as entered.
If you need to use more than one word for the tab name, you must wrap the words in quotes,
single ( ' ) or double ( " ) work equally as well.

TTITLE "today is roughly around ..."


SELECT sysdate FROM dual;

Try it and see. I wonder if TTITLE actually stands for 'Tab Title'? LOL.

How do I change the grid popup editor font?


Another one from the list. Herald asked > I changed the font for the DATA Grids, so I could look
at Unicode. Now I see the chosen font in the datagrid, but if I open the popup editor it still gives
the old font. Is it possible to change this font also, I didn't find it in the options, or could you
make the grid popup editor font the same as the data grid font.

After much searching, Brad supplied the following obvious LOL solution :

*
Go to View → Toad Options → Editor → Behavior.
*
In the Languages section, select "Plain Text" from the dropdown and click the Edit ... button next
to the dropdown.
*
Go to the Highlighting tab and click the "custom font" button.
*
Choose your font and OK your way out.

How do you display an editable drop-down list?


Displaying a drop-down list requires a template column in the grid. Typically, the ItemTemplate
contains a control such as a data-bound Label control to show the current value of a field in the
record. You then add a drop-down list to the EditItemTemplate. In Visual Studio, you can add a
template column in the Property builder for the grid, and then use standard template editing to
remove the default TextBox control from the EditItemTemplate and drag a DropDownList
control into it instead. Alternatively, you can add the template column in HTML view. After you
have created the template column with the drop-down list in it, there are two tasks. The first is to
populate the list. The second is to preselect the appropriate item in the list � for example, if a
book�s genre is set to �fiction,� when the drop-down list displays, you often want
�fiction� to be preselected.

How do you hide the columns?


One way to have columns appear dynamically is to create them at design time, and then to hide
or show them as needed. You can do this by setting a column�s Visible property.

How do you apply specific formatting to the data inside the cells?
You cannot specify formatting for columns generated when the grid�s AutoGenerateColumns
property is set to true, only for bound or template columns. To format, set the column�s
DataFormatString property to a string-formatting expression suitable for the data type of the data
you are formatting.

How do you customize the column content inside the datagrid?


If you want to customize the content of a column, make the column a template column. Template
columns work like item templates in the DataList or Repeater control, except that you are
defining the layout of a column rather than a row.

What is asp.net?
ASP.NET is the latest version of Microsoft's Active Server Pages technology (ASP).

ASP.NET is a part of the Microsoft .NET framework, and a powerful tool for creating dynamic
and interactive web pages

How to sort the data in Datagrid ? when we use DataBound event of Datagrid, I want to
display te data using controls....
For an example,
If i click a button, which is outside of the datagrid, entire data should be shown. 1st column
in TextBoxs. second column in Drop down List Boxs..
How to bind the data in Dropdownlist,which is in DataGrid at run time?
Row1 Row2 Row3 Row4 ----------------- This is the record in datagrid...

When we click button (Bottom of the DataGrid), This Record should be shown...
Row1 in TextBox,,, Row2 in TextBox, Row3 in DropDownlistbox, Row4 in TextBox...
How to do this one?
Which event we should use?
Sorting in DataGrid.Using the SortCommand Event in the datagrid u can sort the value in
datagrid.For Example.Dim con as new oledb.oledbconnection("connectionstring")con.open()Dim
sql as stringsql="query"Dim DataAdapter as new oledb.oledbdataadapter(sql,con)dim ds as new
datasetdataadapter.fill(ds)Private Sub DGMain_SortCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles
DGMain.SortCommand Dim datasort As DataView datasort =
LocalLibrary.GetDataSet(sql).Tables(0).DefaultView datasort.Sort = e.SortExpression
DGMain.DataSource = datasort DGMain.DataBind() End SubBind the data in Datagrid at
runtime ?Use ItemDataBound Event in datagrid.Private Sub DGMain_ItemDataBound(ByVal
sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DGMain.ItemDataBound If e.Item.ItemIndex > -1 Then Dim lblClose As dropdownlist lblClose
= CType(e.Item.FindControl("lblClose"), dropdownlist) If Not lblClose Is Nothing Then
lblclose.items.add("dropdownassignvalue")lblclose.items("dropdownindex").value="assigned
value" End If End If End Sub

How to refresh the data in datagrid automatically?


For refreshing data in data grid control we can use chasing technique

How to add DateTime Control in ormal DataGrid Server Control?


cvv
using template column we can very well add date time control as child contorl

How can I view the Chinese and Japanese character sets through Toad?
Reset NLS_LANG on your Client machine to AMERICAN_AMERICA.JA16SJIS to view
Japanese and AMERICAN_AMERICA.ZHT16BIG5 to view Chinese. Then change the font
script for each language by right clicking on the data and choosing Grid Options | Data Grids -
Visual | Fonts | Grid and choose Arial Unicode MS as the Font. This changes the script to
Japanese for Japanese characters or to ChineseBig5 for Chinese.

How do I copy a whole row or multiple rows of data?


To copy one row of data, put your cursor in a cell in the grid and press Ctrl+Insert. This will
copy the row and its column headers to the clipboard. To copy multiple rows of data, right-click
in the grid and choose "Allow multiselect". Use Shift-Click to select multiple adjacent rows, or
use Ctrl+Click to select individual, non-adjacent rows. Press Ctrl+C. This will copy all of the
rows and their column headers to the clipboard. To copy a single cell's data, turn off "Allow
multiselect". Click on the cell you want to copy and press Ctrl+C.

The following table gives details of what happens with the various copy keys and multi-select
options.
Multi-Select OFF Multi-Select ON
EDIT COPY CTRL+C CTRL+INS EDIT COPY CTRL+C CTRL+INS
One Cell Highlighted Cell only Cell only Row plus headings Cell only Cell Only Row plus
headings
Many Cells(rows) highlighted N/A N/A N/A All highlighted rows plus headings All highlighted
rows plus headings All highlighted rows plus headings

Why can not I add an entry via the grid for a table containing a CLOB column?
In older versions of TOAD, the grid is limited to adding/modifying CLOB's for existing records.
This should be working in TOAD 7.6. Note, however, that since TOAD does not support
Unicode databases, that there are often errors when viewing CLOB data in the data grids for
databases with Unicode character sets.

In DataGrid, is it possible to add rows one by one at runtime. That means after entering
data in one row next row will be added?
Yes, for this you have to use datatable and after inserting the first row in datatable u have to bind
that datatable to the grid and next time , first u have to add the row in datatable and next bind it
to datagrid. keep on doing.
u have to maintain the datatable state.

Вам также может понравиться