C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Build up a DataSet


Posted Date: 08 May 2008    Resource Type: Code Snippets    Category: ADO.NET

Posted By: komaladevi       Member Level: Gold
Rating:     Points: 5




Imports System.Data.SqlClient
Imports System.Data

Module Module1

Sub Main()
Try
Dim DS As New DataSet()

DS.ReadXml("Authors.XML")

Dim XMLContent As String = DS.GetXml()

Dim I As Integer

For I = 0 To DS.Tables(0).Rows.Count - 1
DS.Tables(0).Rows(I).Item("Author") = UCase(DS.Tables(0).Rows(I).Item("Author"))
Next

For I = 0 To DS.Tables(0).Rows.Count - 1
Console.WriteLine(DS.Tables(0).Rows(I).Item("Title"))
Console.WriteLine(DS.Tables(0).Rows(I).Item("Author"))
Console.WriteLine(DS.Tables(0).Rows(I).Item("Publisher"))
Console.WriteLine(DS.Tables(0).Rows(I).Item("Price"))
Next

DS.WriteXml("NewAuthors.xml")

Catch Ex As Exception
Console.WriteLine("Exception: " & Ex.Message)
Console.WriteLine(Ex.ToString)
Console.ReadLine()
End Try

End Sub

End Module




Responses

Author: Balamurali Balaji    08 May 2008Member Level: Diamond   Points : 2
Hi,

You've built a dataset from a xml file. There is no proper explanation for this, instead you write more code to get the xml back from the dataset and read the dataset row by row to display data on the console, which is not required.

Please add few lines of explanation and correct the code accordingly.

Goodluck


Author: komaladevi    08 May 2008Member Level: Gold   Points : 2
Thank you for your feed back


Author: komaladevi    08 May 2008Member Level: Gold   Points : 2
as this is the code snippet i gave the simple code if u want me to explain then its okay i will


Author: vivek kushwaha    08 May 2008Member Level: Silver   Points : 2
'' Alternative of XML.
this is a master class function which returns dataset according to parameters.


Public strconnect As String = (ConfigurationSettings.AppSettings("dsn_SQL"))

Public Function sendDataset(ByVal strsql As String, Optional ByVal Addnewrecord As Boolean = False) As DataSet
Try
Dim connection As New SqlClient.SqlConnection(strconnect)
connection.Open()
Dim adapter As New SqlClient.SqlDataAdapter(strsql, connection)
Dim dataset As New DataSet
Dim Dtype As String
adapter.Fill(dataset)
If Addnewrecord = True Then
Dim myNewRow As DataRow
Dim rowVals(dataset.Tables(0).Columns.Count - 1) As Object
rowVals(0) = 1
myNewRow = dataset.Tables(0).Rows.Add(rowVals)
End If
sendDataset = dataset
adapter.Dispose()
connection.Close()

Catch err As Exception
Throw (err)
End Try
End Function


Author: Balamurali Balaji    08 May 2008Member Level: Diamond   Points : 2
Hi,

You haven't stated the purpose of the code snippet clearly and explained the same.

Please add few explanations and remove the un-wanted code.

Good luck


Author: vivek kushwaha    08 May 2008Member Level: Silver   Points : 2
post this fuction in the main class file.
use the function on which form you want to fill dataset using your query.



Author: vivek kushwaha    08 May 2008Member Level: Silver   Points : 2
'like create a form form1.aspx
'create an object of class class1.vb in which above function exist.
dim clsm as new class1
'on page load event
clsm.senddataset("select * from table1")

''all you got.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Filter record and fill like a auto fill combobox
Previous Resource: how to use a SqlDataAdapter to get data from a database into a DataSet.
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween masks

Contact Us    Privacy Policy    Terms Of Use