Thursday, June 18, 2009

DataRowStates of DataSet

Programmers always look for shortcuts and ease while he perform his job. Microsoft provides a number of Services in this Regard. VisualStudio.NET is one of the remarkable development of Microsoft. (Enough to talk about Microsoft)


Here, I want to tell you that how can we get only that data from DataSet which we manipulate while we were performing our job.

DataSet has a number of DataRowState Properties:

1) DataRowState.Added
2) DataRowState.Deleted
3) DataRowState.Modified
4) DataRowState.Detached
5) DataRowState.Unchanged


DataRowState help us in getting the manipulated data which we either Change, Delete or Add.

Now, How can we use these state. I am telling you below but first we have to fill a dataset by any values. For Example, I create my own database. Insert values in it and after then I call them through query into dataset.

Here, I assume that you must have fill your dataset already. Now change a value of any row from your dataset. To get confirmation that something is changed you can use the below command:

MessageBox.Show(dataSetName.HasChanges)

If it return you "True" then we get confirmed that something is modified in dataset. Now you can get all the changes either modified rows, added rows, deleted rows, etc. by single command

ds.GetChanges()

or you can get only those deleted/Modified/Added rows by following the below code:

ds.GetChanges(DataRowState.Modified)

The above command will return you only updated rows.

Below I am writing entire Code for the easiness of your sake:


/////////////Form Loaded Method//////////////////////
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

MyBase.Load
Try
con.Open()
da = New SqlDataAdapter("select * from tblstudent_Main", con)
da.SelectCommand.ExecuteNonQuery()
da.Fill(ds, "table1")
con.Close()
ds.Tables(0).Rows(1).Item(1) = "Zeeshan"
ds.Tables(0).Rows(5).Item(1) = "Ahmed"
Dim dr As DataRow
dr = ds.Tables(0).NewRow
dr.Item(0) = 7
dr.Item(1) = "Memon"
ds.Tables(0).Rows.Add(dr)
Catch ex As Exception

End Try
End Sub



//////////Button Click Method/////////////////
MessageBox.Show(ds.HasChanges)
Dim ds2 As New DataSet
ds2 = ds.GetChanges()
For Each dr As DataRow In ds2.Tables(0).Rows
///Return True if the rows are added else False

''MessageBox.Show(ds2.HasChanges(DataRowState.Added))

//Return you DataRowState. Remember if you do not write toString() then
it will return you numeric value.

MessageBox.Show(dr.RowState.ToString)

Next
DataGridView1.DataSource = ds2.Tables(0)

MessageBox.Show("transfereed successfully")


I hope that this will help you alot in understanding the DataRowState Concept.

Wednesday, June 10, 2009

PARAMETERS REQUIRED IN CRYSTAL REPORT

Dear Friends, When I was new to Crystal Report in Visual Studio. The very first problem that I was encoutered was how to pass parameters to Crystal Report from vb.net. And I was amazed when I found the solution quite easy.

Solution:

You must first make an instance of the report object

dim rpt as new reportname

now you can pass the parameter to report

rpt.setparametervalues("ParameterName",value)

For Example

rpt.setParameterValues("Name",value)

I hope this will help you alot.

Invalid Report File Path

Dear Friends, Last days I was very upset due to a minute problem which make my life hell, and when I discover its solutions I was amazed that how much easy it was to resolve.

Problem:
I create a report in Visual Studio 2003 in vb.net. The report display its results but when I give it command to print the document or to export the document then it shows me an error which says

"Invalid Report File Path"

I google on web alot and found a huge number of solutions too but neither work for me.

Solution:
The solution was quite simple. I have written all the queries and codes in FormName_Activated() Method. I just cut the code from there and paste it to FormName_Load() Method.

And get the result which I want.

It now not only export the report but also print the report too.

Ohh..... GOD some times a minor problem becomes a huge one and have a very minute solution but only the problem is to discover it..............

I hope this will help you as well.

Wish you all the best......................

Wednesday, June 3, 2009

INSTANCE OF REFERENCE IS DISPOSED

Some times we have a situation where we dispose the reference instance and then later on we try to use it and it gives us an exception

"Cannot access a disposed object".

The simple solution of the above problem is that you first check that either the instance of the reference is not disposed. If it is disposed then create a new instance of the reference and to check that either the instance of the reference is alive or not, we simple write the following code

if frm.IsDisposed()=true then
frm=new form1
end if

That's all....

Enjoy the world of Programming.

Wednesday, May 27, 2009

DATAGRID INSIDE COMBOBOX

Dear All,

Once my client demand me to provide combo box inside datagridview. I have searched a number of articles but was unsucessfull to know that how to get the value from combo box. On the below link you will find the program in winrar format. Extract it and enjoy.

After Opening this link, search for windowsApplication1.rar.

http://tech.groups.yahoo.com/group/universal_programmersgroup/files/

Saturday, May 2, 2009

CRYSTAL REPORT INSTR() FUNCTION

Many Novice/Professional users face a common error "A boolean is required here" while using Instr() Function in Crystal Report. They try to give true /false or 0/1 value. But still failed in getting the desired result.

Instr() Function take the Index if it find the given text in the defined string. So the simple solution of the problem is

if Instr(string from where to search , string that is searched) > 0 then
"Type the message if the search is successfull"
else
"Type the message if the search is Unsucessfull"

I hope that you will understand it this time and after then in entire your life you will not forget it.

Monday, April 27, 2009

CLOUD TECHNOLOGY

Cloud Computing [ known as Softwares as a Service (SaaS), and also as on-demand software ] is a new technique in which you can access the services and software application on your system without the need of installing software applications and services on your end. The reason behind this is that all these services/applications are provided to you from any system that is enrolled or part of the cloud.

Cloud computing is a computing paradigm in which tasks are assigned to a combination of connections, software and services accessed over a network. This network of servers and connections is collectively known as "the cloud." Computing at the scale of the cloud allows users to access supercomputer-level power. Using a thin client or other access point, like an iPhone,
BlackBerry or laptop, users can reach into the cloud for resources as they need them. For this reason, cloud computing has also been described as "on-demand computing."

An example of Cloud Computing is Google Apps, which provides common business applications online that are accessed from a web browser, while the software and data are stored on Google servers.

Cloud Technology is a style of computing in which typically real-time scalable resources are provided “as a service” over the Internet to users who need not have knowledge of, expertise in, or control over the technology infrastructure ("in the cloud") that supports them.

Docker Tutorial

 I have listed all the necessary commands of Docker below. In case if any is missing or if any improvement required, please share in comment...