G
Guest
I am trying to use strongly typed Dataset Objects in my project but I seem to be missing something
I created a class library project named DSCommon. I then used the Server Explorer to create an XML Schema of my Oracle table and then I generated a DataSet (http://www.developer.com/db/article.php/10920_3069061_2)
I then created a second windows application project and added a reference to DSCommon
I have one text box, navigation buttons, and a command button on the form. I have tried the following code but I do not seem to have the benefits of a strongly typed dataset - I cannot do anything like txtPlaneType.text = ds.PlaneTypes[0].planedesc
(I added a reference to Oracle.DataAccess to the windows app. project.
<code
Imports Oracle.DataAccess.Clien
Imports DSCommo
Public Class Form
Inherits System.Windows.Forms.For
Dim conn As New OracleConnectio
Dim cmPlaneTypes As CurrencyManage
...
Private Sub connectDatabase(
conn.ConnectionString = "User id=username;Password=password;Data Source=server.com;
Tr
conn.Open(
Catch ex As Exceptio
Throw e
End Tr
End Su
Private Sub closeDatabase(
conn.Close(
End Su
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Clic
Tr
Me.connectDatabase(
Dim planeTypeAdapter As OracleDataAdapter = New OracleDataAdapte
planeTypeAdapter.SelectCommand = New OracleCommand("SELECT PLANETYPE, PLANETYPEDESC FROM PLANETYPES", conn
Dim PlaneTypeDataSet As New PlaneType
planeTypeAdapter.Fill(PlaneTypes, "PlaneTypeDataSet"
cmPlaneTypes = CType(BindingContext(PlaneTypeDataSet, "PlaneTypes"), CurrencyManager
AddHandler cmPlaneTypes.ItemChanged, AddressOf cmPlaneTypes_ItemChange
AddHandler cmPlaneTypes.PositionChanged, AddressOf cmPlaneTypes_PositionChange
txtPlaneType.DataBindings.Add("Text", PlaneTypeDataSet.PLANETYPES, "PLANETYPEDESC"
Catch ex As Exceptio
MessageBox.Show("At this time this information cannot be viewed or updated.", "Error retrieving records", MessageBoxButtons.OK, MessageBoxIcon.Error
Finall
If conn.State = ConnectionState.Open The
Me.closeDatabase(
End I
End Tr
' is this needed
conn.Dispose(
end su
...
</code
This is the schema in the first project
<code><?xml version="1.0" encoding="utf-8" ?><xs:schema id="PlaneTypes" targetNamespace="http://tempuri.org/PlaneTypes.xsd" elementFormDefault="qualified
xmlns="http://tempuri.org/PlaneTypes.xsd" xmlns:mstns="http://tempuri.org/PlaneTypes.xsd
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="PlaneTypes"><xs:complexType><xs:choice maxOccurs="unbounded"><xs:element name="PLANETYPES"><xs:complexType><xs:sequence><xs:element name="PLANETYPE" type="xs:integer" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1
msdata:AutoIncrement="true" /><xs:element name="PLANETYPEDESC" type="xs:string" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><xs:unique name="DocumentKey1" msdatarimaryKey="true"><xs:selector xpath=".//mstnsLANETYPES" /><xs:field xpath="mstnsLANETYPE" /></xs:unique></xs:element></xs:schema></code
How do I create this at run time and get the benefits in design time
Is there a better way to reference the code for the navigation buttons
I created a class library project named DSCommon. I then used the Server Explorer to create an XML Schema of my Oracle table and then I generated a DataSet (http://www.developer.com/db/article.php/10920_3069061_2)
I then created a second windows application project and added a reference to DSCommon
I have one text box, navigation buttons, and a command button on the form. I have tried the following code but I do not seem to have the benefits of a strongly typed dataset - I cannot do anything like txtPlaneType.text = ds.PlaneTypes[0].planedesc
(I added a reference to Oracle.DataAccess to the windows app. project.
<code
Imports Oracle.DataAccess.Clien
Imports DSCommo
Public Class Form
Inherits System.Windows.Forms.For
Dim conn As New OracleConnectio
Dim cmPlaneTypes As CurrencyManage
...
Private Sub connectDatabase(
conn.ConnectionString = "User id=username;Password=password;Data Source=server.com;
Tr
conn.Open(
Catch ex As Exceptio
Throw e
End Tr
End Su
Private Sub closeDatabase(
conn.Close(
End Su
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Clic
Tr
Me.connectDatabase(
Dim planeTypeAdapter As OracleDataAdapter = New OracleDataAdapte
planeTypeAdapter.SelectCommand = New OracleCommand("SELECT PLANETYPE, PLANETYPEDESC FROM PLANETYPES", conn
Dim PlaneTypeDataSet As New PlaneType
planeTypeAdapter.Fill(PlaneTypes, "PlaneTypeDataSet"
cmPlaneTypes = CType(BindingContext(PlaneTypeDataSet, "PlaneTypes"), CurrencyManager
AddHandler cmPlaneTypes.ItemChanged, AddressOf cmPlaneTypes_ItemChange
AddHandler cmPlaneTypes.PositionChanged, AddressOf cmPlaneTypes_PositionChange
txtPlaneType.DataBindings.Add("Text", PlaneTypeDataSet.PLANETYPES, "PLANETYPEDESC"
Catch ex As Exceptio
MessageBox.Show("At this time this information cannot be viewed or updated.", "Error retrieving records", MessageBoxButtons.OK, MessageBoxIcon.Error
Finall
If conn.State = ConnectionState.Open The
Me.closeDatabase(
End I
End Tr
' is this needed
conn.Dispose(
end su
...
</code
This is the schema in the first project
<code><?xml version="1.0" encoding="utf-8" ?><xs:schema id="PlaneTypes" targetNamespace="http://tempuri.org/PlaneTypes.xsd" elementFormDefault="qualified
xmlns="http://tempuri.org/PlaneTypes.xsd" xmlns:mstns="http://tempuri.org/PlaneTypes.xsd
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="PlaneTypes"><xs:complexType><xs:choice maxOccurs="unbounded"><xs:element name="PLANETYPES"><xs:complexType><xs:sequence><xs:element name="PLANETYPE" type="xs:integer" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1
msdata:AutoIncrement="true" /><xs:element name="PLANETYPEDESC" type="xs:string" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType><xs:unique name="DocumentKey1" msdatarimaryKey="true"><xs:selector xpath=".//mstnsLANETYPES" /><xs:field xpath="mstnsLANETYPE" /></xs:unique></xs:element></xs:schema></code
How do I create this at run time and get the benefits in design time
Is there a better way to reference the code for the navigation buttons