|
Using VB.net
Can somebody help me? I'm using vb to connect to MySQL through ODBC using the following code
<br />
Dim Con as New ODBCConnection("some connection")<br />
Dim Adp as New ODBCDataAdapter<br />
Dim ds as New DataSet()<br />
<br />
Con.Open()<br />
Adp.SelectCommand.Connection = Con<br />
Adp.SelectCommand.CommandText = "SELECT * FROM tablename"<br />
Adp.Fill(ds,"tablename")<br />
The error occurs at the Fill with message: NO_DATA, but if I use ExecuteReader instead, there's no error and the data's there.
Is there something wrong with the code? Or is there something I should know about the Microsoft.Data.Odbc namespace? Please Help!
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Microsoft just recently announced that the "Everett" version of .Net will be released as .Net 2003. The beta version is available for download on their dev site. They have not said anything about upgrade policies for current owners of .Net. Does anyone have any info on this yet?
|
|
|
|
|
For Visual Studio .NET 2002 customers who do not subscribe to MSDN or to a Microsoft volume licensing program, Microsoft is committed to providing an inexpensive path to "Everett." Registered users of Visual Studio .NET 2002 will be able to license "Everett" for $29 US, the cost of materials, shipping and handling, for a limited time after release. Availability will be roughly concurrent with Windows .NET Server 2003. For those customers who prefer not to upgrade to Visual Studio "Everett," a service pack offering only bug fixes for Visual Studio .NET 2002 will be available soon after the "Everett" release.
from
http://msdn.microsoft.com/vstudio/productinfo/roadmap.asp[^]
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
I am doing something on my IExplorer.I have the form which set as
automaximize is true for every say 1 hour.So every 1 hour my form
awakes.Suppose if it gets activated,my focus will go from IE to vbform.how
to avoid this.i want to do my focus again to my IE.How to do.
1.i want API to activate another application.
2. i want to get the handle of the deactivation window, so that again i
activate the window.
|
|
|
|
|
Hi,
Please I need help,
I have a groupbox that contains 2 radiobuttons. So i want to bind to it a datafield (having only 2 values : 1 for the first radiobutton, or 2 for the second radiobutton).
Please can someone show me how to use databinding with this groupbox.
Thank you in advance.
Intibnin...
***
|
|
|
|
|
From what I understand in your message, you have:
Form
- GroupBox
- RadioButton1
- RadioButton2
You also have a dataset where each row has 1 column (or more). If this column has a value of 1 you want RadioButton1 to be selected, otherwise RadioButton2.
Can you clarify your situation a bit more? Are you using typed/untyped datasets? Are you using C#, VB, or J#?
I dont see how this isn't just basic databinding - and if it is you'd be better off checking MSDN for the documentation on DataBinding.
Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript)
tatham@e-oddie.com
+61 414 275 989
|
|
|
|
|
Thank Tatham for help.
Well, the problem i encountred is in VB.NET Form.
I try to clarify the problem, so the dataset used in form is filled programmatically. I create a method for binding fields to dataset as follows :
Private Sub BindingFields()
cn = New SqlClient.SqlConnection(constring)
Dim da As New SqlClient.SqlDataAdapter("select * from parametres where type = 1 order by code ", cn)
'Note : Mydataset, MyBuilder and MyAdapter are declared public objects
Mydataset = New DataSet()
MyAdapter = New SqlClient.SqlDataAdapter("select * from client", cn)
MyBuilder = New SqlClient.SqlCommandBuilder(MyAdapter)
MyAdapter.Fill(Mydataset, "client")
TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_codcli"))
TextBox2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_adrcli"))
TextBox3.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.tel1"))
TextBox4.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_nomcli"))
TextBox5.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.tel2"))
TextBox6.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.fax"))
TextBox7.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.dat_cre"))
da.Fill(Mydataset, "Categorie")
ComboBox1.DataSource = Mydataset
ComboBox1.DisplayMember = "Categorie.libelle"
ComboBox1.ValueMember = "categorie.cat_cli"
'*****************************
'The problem is here
'Client.stop_serv is 1 or 2
'******************************
GroupBox2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.stop_serv"))
End Sub
this code does not work.
Thank you in advance
***
|
|
|
|
|
Either:
RadioButton1.DataBindings.Add(New System.Windows.Forms.Binding("Value", Mydataset, "client.stop_serv1"))<br />
<br />
RadioButton2.DataBindings.Add(New System.Windows.Forms.Binding("Value", Mydataset, "client.stop_serv2"))
Or, can you just use a check box and bind the Checked property?
Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript)
tatham@e-oddie.com
+61 414 275 989
|
|
|
|
|
Hi,
Please I need help.
I created a form that allows me searching customers by name. after display customers list in datagrid, i want allow user to select one customer by pressing key.
for grid setup, i tried the following code :
'Configuration de la grille
Private Sub DataGridSetup()
Dim ts As New DataGridTableStyle()
Dim cs As New DataGridTextBoxColumn()
AddHandler cs.TextBox.KeyPress, AddressOf CellKeyPress
DataGrid1.ContextMenu = ContextMenu1
DataGrid1.CaptionText = "Résultat"
ts.MappingName = "mycli"
cs.MappingName = "c_cli"
cs.HeaderText = "Code"
cs.Alignment = HorizontalAlignment.Center
ts.GridColumnStyles.Add(cs)
cs = New DataGridTextBoxColumn()
cs.MappingName = "N_cli"
cs.HeaderText = "Nom/Raison sociale"
ts.GridColumnStyles.Add(cs)
DataGrid1.TableStyles.Clear()
DataGrid1.TableStyles.Add(ts)
End Sub
and i added handler to datagridtextboxcolumn, for detecting the keypress events as follows :
'Ajout d'un évènement aux cellules
Public Sub CellKeyPress(ByVal Sender As Object, ByVal e As KeyPressEventArgs)
Dim dt As DataTable = ds.Tables("mycli")
Dim p As Integer
CodeClient = Space(11)
If e.KeyChar = Chr(13) Then
p = Me.BindingContext(ds, "mycli").Position
CodeClient = dt.Rows(p)("c_cli")
Me.Close()
End If
End Sub
So after writing this code, i can select one customer only after pressing SHIFT+RETURN.
please can you explain me way i must first press
SHIFT.
Thank you very match.
Intibnin...
***
|
|
|
|
|
The return key is captured to end edits. If you begin editing a DataGridTextBoxColumn and then press enter the edit will end.
If you want to override this you'll have to be really careful or edits or use the column as read-only.
The easiest (maybe only) way to do this would be to creat your own wrapper which inherits the DataGridTextBoxColumn class. Eg:
Public Class DataGridTextBoxSelectorColumn<br />
Inherits DataGridTextBoxColumn<br />
<br />
Public ...<br />
End Class
From here you should be able to override the key events. Be careful that if your not going to actually do anything on the event that you call the equivalent MyBase.whatever event.
Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript)
tatham@e-oddie.com
+61 414 275 989
|
|
|
|
|
Hi Tatham,
Thank you for your help.
I tried your code bu it doesn't work.
if you can clarify more.
I attract your attention that the return key is completely omitted in the datagrid and all the other keys work correctly. Probably because <enter> key appears in the list of keyboard shortcut of the datagrid control
thank you for advance.
intibnin
***
|
|
|
|
|
Sorry, I cant really help much more. I dont have any other ideas.
Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript)
tatham@e-oddie.com
+61 414 275 989
|
|
|
|
|
Uh, I am sorta new at this toolbar thing. Can someone give me the syntax of how to make the toolbar buttons do something? It has to do with toolbar_buttonclick () I am pretty sure. Please help
|
|
|
|
|
If it is VB6...
When you set the properties for your toolbar, you have to set the key for each button, for example, "IDX_NEW","IDX_OPEN", etc.
Then
<br />
Private Sub toolbar_ButtonClick(ByVal Button as MSComctlLib.Button)<br />
Select Case Button.Key<br />
Case "IDX_NEW"<br />
coding<br />
Case "IDX_OPEN"<br />
coding<br />
........<br />
<br />
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
hi
my name is rachel and I need help.
I don't know how to use the controls:LabelArray and MenuItemArray
|
|
|
|
|
Both these object are from the vb6.compatibility namespace and are used to represent control array when upgrading a project from vb6 to .net. Microsoft does not recommend the use of these objects for new .net projects sinse they will not support it in later versions. However, if you still want to use them...
First add the controls to the form, say lblArray,lbl_0,lbl_1,lbl_2
then
<br />
Public Sub Form_Load()<br />
lblArray.SetIndex(lbl_0,Ctype(0,Short)<br />
lblArray.SetIndex(lbl_1,Ctype(1,Short)<br />
lblArray.SetIndex(lbl_2,Ctype(2,Short)<br />
End Sub<br />
You can then reference these controls as lblArray(i), where i = 0,1,2
though IMHO, it's better than you not use them. Instead just declare an array of labels and assign each control to it
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Dear All,
I am having difficulty in running the following code: -
Basically, i am writing this code in Window XP and it run well. But, when i changed to
Window 98, it run the notepad.exe, but also pup-up the message box. May i know what is the problem here. The followings are the exact code that i used in XP and 98.
Thank in advance. Merry Xmas n happy new year...
Dim x As Integer
Private Sub Form_Load()
On Error GoTo Err
x = Shell("Notepad.exe", vbHide)
Unload Me
Exit Sub
Err:
MsgBox "File Not Found", vbCritical
Unload Me
End Sub
|
|
|
|
|
in the error handler take a look at the error message and error number to give an indication as to why your handler is being called.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
I defined a function like this:
func(byref x as ADODB.Connection)
then i :
Dim conn as New ADODB.Connection
afterwards i:
func(conn)
but when i compiled it, i met a error. How to write correctly?thanks much
|
|
|
|
|
What does the error say? what about the error code?
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
type mismatch
|
|
|
|
|
Try this:-
<br />
call func(conn)<br />
or
<br />
func conn<br />
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
thanks,i solved the type mismatch by your advice.
|
|
|
|
|
But do you understand WHY this worked? I think that is more important.
Using parens in VB mandates that your function RETURN something.
For example:
Public Function AddNumbers(numOne As Integer, numTwo As Integer) As Ineteger
Dim retVal as Integer
retVal = numOne + numTwo
AddNumbers = retVal
End Function
This function would be called like so:
Dim answer As Integer
answer = AddNumbers(1, 2)
If you have a Subroutine they generally don't return anything. This is afterall the main difference between a Function and a Subroutine. Functions do soemthing AND return something.
Given a Subroutine as such:
Public Sub DisplaySomething(something As String)
Debug.Print something
End Sub
Because this does not return anything it has to be called one of the following ways:
DisplaySomething "Hello World."
-or-
Call DisplaySomething("Hello World.")
This is one of the reasons that alot of people don't like VB. They feel confused by needing to rememebr if they have to use parens or not.
Generally speaking i think that using the Call keyword is bad form though. Simply don't use parens and all is fine.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
Ray Cassick wrote:
rememebr if they have to use parens or not.
Tell me about it !
And for someone like me who alternates between .net and vb6, it can get even more confusing! Thank god for .net's intellisense. I just don't bother with parens at all.
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|