|
IMO a database table is a one-dimensional array holding rows; each row holds fields of different types, something an array isn't capable of in most languages.
In C#, C/C++, or VB.NET a row could be represented by a class or struct, where each field corresponds to one field of the datatable row.
Do not use multi-dimensional arrays if you don't really need them, and don't use parallel one-dimensional arrays either: use more structured data, as in an array of structs/classes.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thats very useful
thanks for the fast reply
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
This is a stub version of the actual problem.
Here are two files. Form1.vb, which looks like this:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myIKGrid As New IKGrid
myIKGrid.Columns(0).Caption = "English"
myIKGrid.Columns(0) = "Zero"
End Sub
End Class
You cannot modify Form1 for any reason whatsoever.
The other file is IKGrid.vb. It looks like this:
Public Class IKGrid
Public Property Columns(ByVal s As Short) As IKColumn
Get
Return Nothing
End Get
Set(ByVal value As IKColumn)
End Set
End Property
End Class
Public Class IKColumn
Public Property Caption() As String
Get
Return ""
End Get
Set(ByVal value As String)
End Set
End Property
End Class
You can modify IKGrid any way you please.
Anyway, this code results in a compile error. The line:
myIKGrid.Columns(0) = "Zero"
causes
Value of type 'String' cannot be converted to 'IKColumn'
So, how can you modify the IKGrid file so that the String CAN be converted to an IKColumn? The project doesn't need to do anything useful, it just needs to be able to compile without errors.
|
|
|
|
|
i_kant_spel wrote: The project doesn't need to do anything useful
Interesting prospect.
From myIKGrid.Columns(0) = "Zero" it would seem IKGrid.Columns[] is a string array, however you can't get myIKGrid.Columns(0).Caption = "English" right since a string doesn't have a Caption property.
Hence, IKGrid.Columns must be a type that has a Caption property, and has an override for the = operator.
The remainder is left as your homework.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Override for the = operator? Only in C++ where nothing means anything because everything can be overriden. There are not overrides for assignment in .NET (or VB6 for that matter), though with default properties, it could sometimes look that way.
|
|
|
|
|
Now you killed the homework completely!?
there is an "operator implicit" in C# that would let you cast automatically, don't know how VB.NET stands on this.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
It's got to be possible somehow. The original project uses commercial libraries, which I don't have access to at this time. I'm trying to create dummy classes. For the time being, I don't need the functionality of the real classes. I just need the existing code to compile correctly as it is.
Whatever type IKGrid.Columns(0) returns, it definitely has a "caption" property and it does something that makes it possible to assign a String to it with the equals operator. But I still have no idea how that's done. I've looked into overloading operators in VB.NET, but I can't find information regarding the equals sign as an assignor, only as an equality tester.
|
|
|
|
|
There's a bit of a disconnect between your initial question and its restrictions. Either you can recompile the form class, which means you can change it to just use the caption property, or you can't recompile it and you can't do anything to IKGrid either because the form has already bound to it. (Well, you may be able to change some things, but nothing that will make your situation work.)
Regardless, Luc and I have dropped some hints about how to do what you want in other posts in the thread.
|
|
|
|
|
Well, yes there are conversion operators I suppose (Widening Operator CType would be equivalent to implicit, I believe)
Personally, my solution is fix the code in the form, but if the situation doesn't allow, then I guess there are plenty of ways to get around it. Though if it's not homework, one wonders how it compiled in the first case.......
|
|
|
|
|
Adding a Widening Operator CType to the dummy class worked. So I guess it compiled in the first place because the class in the commercial library does something similar.
|
|
|
|
|
Unless I am missing something, doesn't the Caption property of the IKColumn class need to be set as the default property?
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I haven't set any default properties. It compiles fine without default properties. The IKGrid.vb file looks like this now:
Public Class IKGrid
Public Property Columns(ByVal s As Short) As IKColumn
Get
Return Nothing
End Get
Set(ByVal value As IKColumn)
End Set
End Property
End Class
Public Class IKColumn
Public Shared Widening Operator CType(ByVal src As String) As IKColumn
Return Nothing
End Operator
Public Property Caption() As String
Get
Return ""
End Get
Set(ByVal value As String)
End Set
End Property
End Class
And I can call myIKGrid.Columns(0).Caption = "English" just fine without Caption being a default property.
|
|
|
|
|
Ah yes but if you define your property like so:-
Public Default Property Caption() As String
Then you can assign the caption as follows :-
myIKGrid.Columns(0) = "English"
Which I believe is what you are trying to achieve, or am I wrong?
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I have created a project, and with form3, created a class for datagridview called MyDtGrd. And when I created a form4 I used that same MyDtGrd. When I used before to publish the program no problem.
But after publishing When I tried to make changes, giving error like
"The variable MyDtGrd is either undeclared or was never assigned"
Is there any technique to access the same class oject to use in other forms?
Thank You !
|
|
|
|
|
Simply pass the reference from one to the other.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Is there a way within vb to find which window has focus on a computer? For instance if IE, Open Office Writer and Photoshop are open, how can I programmatically tell which one has focus?
|
|
|
|
|
This would need some code class to native window function, here is C# code you can port it to VB
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class MyClass
{
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
public static void Main() {
IntPtr handle = GetForegroundWindow();
}
}
|
|
|
|
|
have created function in class file.
Public Shared Function dsCntrctET() As DataSet
Dim sqlCntrct As String = "Select * from CNTRCT_ET where CNTRCT_ID=" & CISCNO
Dim cmdCISContract As New OracleCommand
Dim daCISCntrct As New OracleDataAdapter
Dim dsCISCntrct As New DataSet
Dim cmdCISBuilder As New OracleCommandBuilder
Try
With cmdCISContract
.Transaction = myTransCIS
.CommandText = sqlCntrct
.Connection = cnCIS
End With
daCISCntrct = New OracleDataAdapter(cmdCISContract)
daCISCntrct.FillSchema(dsCISCntrct, SchemaType.Source)
cmdCISBuilder = New OracleCommandBuilder(daCISCntrct)
With daCISCntrct
.TableMappings.Add("Table", "CNTRCT_ET")
.Fill(dsCISCntrct)
.SelectCommand = cmdCISContract
.InsertCommand = cmdCISBuilder.GetInsertCommand
.UpdateCommand = cmdCISBuilder.GetUpdateCommand
.DeleteCommand = cmdCISBuilder.GetDeleteCommand
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Return (dsCISCntrct)
End Function
it returns dataset that i can use for getting value from table.
but while saving data, i have to use dataadapter for da.update(ds,"table") and ds.acceptchanges.
this i have to use in multiple forms as this data comes from 3rd party so i dont want to write this in every form . so i thought how to return data adapter and dataset from the same function. as i wanted to use daCISCntrct and dsCISCntrct.
When i am saving data , and i call CISCLASS.daCISCntrct.update(CISCLASS.dsCIScntrct,"Table_Name")..it goes to function and initialize datadapter and not saving new data . it not giving me error but if i look at table, it has all old data where as if i write this code in private sub procedure , its saving data and next time i see new data in the table.
Please reply me asap.
Thanks in adavance.
|
|
|
|
|
You've posted this question numerous times now and I do believe you've been given the answer. If you don't understand the answer reply to the original post and seek clarification.
Anyway, the simple way is to change the function to a sub with two parameters, one of type DataSet and the other of type DataAdapter. Mark these parameters with the ByRef keyword (I think, I haven't done VB for quite some time) and then when you call the sub pass in an empty dataset and an empty data adapter. Inside of the sub, before you exit and at the same time as you would normally return, set the parameters to the values of daCISCntrct and dsCISCntrct, they will then be available to the calling function.
|
|
|
|
|
i understand that bu the problem now is its not saving the data when i say da.update and ds.aceeptchanges.
as when i call the da.update, it goes to da function and initialize evetything so doesnt change values in table.
how to do update and acceptchanges to the table
|
|
|
|
|
I have done a project, and I put in my network folder for users. Also I checked from my user machine it works fine.
But the problem is after making the alteration, I changed the Pblish Version-revision as 0 again. And again I put the program in network same folder I checked it was not changed in users machine...why?
really I get cinfused...
Anybody can point me, the mistake ?
Thanks
|
|
|
|
|
Are you talking about a Windows app or Web?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
windows application
Thanks
|
|
|
|
|
If i understand you correctly you have compiled you project and publish it and the changes you made does not take effect on app that you put in the network folder ?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|