|
You can either load the XML file into a DataSet, which will treat it just like a DataSet returned from a database, or you can load it into an XmlDocument and use normal XML methods to manipulate it.
It sounds like all you want to do is iterate over a set of records so, to get your XML into a DataSet, all you have to do is:
Dim myData As New DataSet
myData.ReadXml(filepath)
There are various overloads of ReadXml, so use whatever is appropriate for your case.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thx for help but I still have got a problem.
Here is an extract of my xml file :
< ?xml version = '1.0'?>
< PAGE>
< DATA>
< DATA>
< seance i_seance="218765344" d_date="20060919" d_debut="13:30" d_fin="15:00" d_jour="mardi" n_semaine="38" type_seance="Enseignement">
< x_remarques>Groupe A non bilingue et B</x_remarques>
< ressource type="enseignant" libelle="MR X"/>
< ressource type="volee" libelle="Information documentaire, 2006-2007, S1"/>
< ressource type="matiere" code="7612F" libelle="Sociologie des organisations (Cours)"/>
< ressource type="classe" libelle="ID1B"/>
< ressource type="classe" libelle="ID1A Non bilingue"/>
< ressource type="espace" libelle="C101"/>
< /seance>
< seance i_seance="218766590" d_date="20060919" d_debut="15:15" d_fin="16:45" d_jour="mardi" n_semaine="38" type_seance="Enseignement">
< x_remarques>Groupes A non bilingue et B</x_remarques>
< ressource type="enseignant" libelle="MR A"/>
< ressource type="enseignant" libelle="MR B"/>
< ressource type="volee" libelle="Information documentaire, 2006-2007, S1"/>
< ressource type="matiere" code="7113F" libelle="Introduction � l'archivistique (Cours)"/>
< ressource type="classe" libelle="ID1B"/>
< ressource type="classe" libelle="ID1A Non bilingue"/>
< ressource type="espace" libelle="C101"/>
< /seance>
< /DATA>
< /DATA>
< /PAGE>
I've written the following code but doesn't not display it well :
Sub Main()
Dim myData As New DataSet
Dim mDataRow, mdr As DataRow
myData.ReadXml("test.xml")
For Each mDataRow In myData.Tables(1).Rows
System.Console.WriteLine("date : " & mDataRow("d_date"))
System.Console.WriteLine("Heure début : " & mDataRow("d_debut"))
System.Console.WriteLine("Heure fin : " & mDataRow("d_fin"))
System.Console.WriteLine("Jour : " & mDataRow("d_jour"))
System.Console.WriteLine("Type Séance : " & mDataRow("type_seance"))
For Each mdr In myData.Tables(2).Rows
System.Console.WriteLine(mdr(1) & " : " & mdr(2))
Next
Next
System.Console.ReadLine()
End Sub
Can some1 tell me where I'm wrong .
thx
|
|
|
|
|
VS2005 (vb) and SQL2005
ok im nearly beaten here... think its lack of sleep
I need a very very kind person to help me out as im totally losing the will to live
Ok i have an Default.aspx page with a textbox ( ID TXT1 ) and a Button. what i want to do, what ive been trying to do is when the button is clicked, it basicly does a a "Select count(*) from Table1.dbo.users where name = '" & TXT1.text & "'" and display the return value
ok to some its simple stuff but i have to start somewhere , so please can you explain it in laymans terms
thank you
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Pete,
let's start slow...
1) are you able to establish a database connection from your webpage?
|
|
|
|
|
Hi,
Thanks for the reply. this is all new to me and im struggling like mad. Just for background, Im trying to create an Intra-net project... as a tester. I have my web.config file which has the connection string to the SQL server, and im presuming that if the connection string was incorrect there would be an error. as below
The only conponents i have added are the textbox and Button
section of web.config
<connectionstrings>
<remove name="LocalSqlServer">
<add name="LocalSqlServer"
="" connectionstring="Data Source=DevSQL2;Initial Catalog=TestDataBase;Integrated Security=True" providername="System.Data.SqlClient">
thanks
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
grrr sorry this is what was meant to be added
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=DevSQL2;Initial Catalog=TestDataBase;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
nlarson11
I got an email from the site, but no message on the forum . From the email tho yes i know the connection string is correct.
If its easier you can mail me direct ?
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
look at your webpage.
double click on the button
that will add code for the click event of your button
inside the click event-connect to the database.
run your select statement returning a dataset(ds) using either a helper or an adapter
textbox1.text = ds.tables(0).rows(0)(0)
-- modified at 10:58 Tuesday 24th October, 2006
|
|
|
|
|
This may be simple but I need to display a status message in a label while creating a zip folder. For example, while the folder is being created I want the label to display please wait and when the folder is done I want the label to display finish.
jds1207
|
|
|
|
|
label1.text = "Please Wait..."
'the line below is necessary because the zip is an intesive operation and the label1 may never display the text(or paint itself)
application.doevents
call zipfile()
label1.text=string.empty 'or visible=false
helpful or more to it?
|
|
|
|
|
I am a little confused. Here is the code where I call the functions under the button click:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
When CreateBackupFolder & CreateZip are in progress I want the label to display please wait and when done I want the label to display finish.
I hope I explained this clear enough for you.
jds1207
|
|
|
|
|
So, change your label before you call your Create.... thingy's.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
StatusLabel.Text = "Please wait..."
Application.DoEvents()
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
.
.
.
It would be better if you made a method to change the status label so you can call it from anywhere in your form code though...
Private Sub UpdateStatusUI(ByVal message As String)
StatusLabel.Text = message
Application.DoEvents()
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you! This worked fine.
|
|
|
|
|
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
label1.text = "Please Wait..." '<<<<<<<<<<<<
Application.doevents '<<<<<<<<<<<<
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
label1.text = "Finished" '<<<<<<<<<<<<
End Sub
|
|
|
|
|
Thank you also! Your code is pretty much the same.
|
|
|
|
|
Hi,
Can we use a vb6 file vb.net project. If yes then how it can be done.
Please help me.
Thanks & Regards
Mishra
|
|
|
|
|
There are many different types of files - which one do you mean? Source? Compiled dll? What?
|
|
|
|
|
Although there a lot of similarities between VB6 and VB.NET, VB6 code usually has to be re-written to work properly in VB.NET. For instance, a Long value in VB6 is 32-bit integer whereas it's a 64-bit integer in VB.NET. The equivilent data type to a VB6 Long would be an Integer in VB.NET.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
anyone know about this error message?
System.InvalidCastException:Cast from type 'DBNull'to type 'Date'is not valid
at Microsoft.VisualBasic.CompilerServices.DateType.FromObject(Object Value)
may i know the way to solve it.....
|
|
|
|
|
You're trying to convert a Null value into data type Date which is not allowed. Post your code and either I or someone else will show you where you went wrong & how to fix it.
|
|
|
|
|
'let's say your field is dsRow("DateField")
Dim dtVal as date = cdate(dsRow("DateField")) ' error because of null value
**instead do this**
dim dtVal as date
If isdbnull(dsRow("DateField")) Then
'do notta
Else
dtVal = cdate(dsRow("DateField"))
end if
|
|
|
|
|
Thank you!;)
finally the error solve d...thanks
|
|
|
|
|
Can i take the substraction between 2 date.
Eg: current date is : 2006-10-24
Also, previous date is : 2006-10-18
Them, can i take the current date minus the previous date, so i can take the result is 7days?
Here is the Code:
Dim ChkDate As Date
ChkDate = ChkDate.Now
ChkDate = ChkDate.ToString("yyyy-MM-dd")
'i take the date from dateReader(SQL)
sqlPDate = dtrCheckQty("PurcahseDate").ToString
sqlPDate = sqlPDate.ToString("yyyy-MM-dd")
Dim DiffDate As Integer =Convert.ToInt32(ChkDate.ToString) - Convert.ToInt32(sqlPDate.ToString)
If (diffDate > 5) Then
....
....
End if
How can i solve the problem?
Hope anyone can help me in this problem.
Thanks alot...
-- modified at 16:01 Monday 23rd October, 2006
|
|
|
|
|
You are converting back and forth between strings and dates so many times, that it's a wonder if you would get anything reasonable at all. The part of your code that is compilable actually does this:
Dim ChkDate As Date<br />
ChkDate = ChkDate.Now<br />
ChkDate = Conver.ToDateTime(ChkDate.ToString("yyyy-MM-dd"))<br />
sqlPDate = Convert.ToDateTime(dtrCheckQty("PurcahseDate").ToString)<br />
sqlPDate = Convert.ToDateTime(sqlPDate.ToString("yyyy-MM-dd"))
From what I can see, you try to convert the dates to strings, which is immediately reversed as they are converted back when you store them in the same variable again. Just as well, if you would have succeeded in converting them to strings, you would not be able to get the time difference anyway, as you can't subtract strings.
Then you subtract the dates, which works just fine, but it gives a result of the type TimeSpan, that you try to store in an integer variable. This is of course not possible.
Stop trying to convert the dates to strings, store the result of the subtraction in a TimeSpan variable, and get the time difference in days by using the TotalDays property.
---
b { font-weight: normal; }
|
|
|
|
|
Newbie_dydy85 wrote: sqlPDate = dtrCheckQty("PurcahseDate").ToString
dtrCheckQty("PurcahseDate") is the date to be checked then:
Dim chkDate As Date = CDate(dtrCheckQty("PurcahseDate"))<br />
If DateDiff(DateInterval.Day, Date.Now, chkDate) = -7 Then<br />
' the date within the varaible chkDate is 7 days old<br />
........<br />
........<br />
End If
Hope this helps.
|
|
|
|