|
I think he is kidding us ...
|
|
|
|
|
hi guys,
i am developing an application which uses access mdb files as database.
untill now i used a connection to the files,
using the following code:
Public Class DBconnector
Private _dbConnection As OleDbConnection
Private _dbCommand As OleDbCommand
Private _dbDataReader As OleDbDataReader
Private _dbDataAdapter As OleDbDataAdapter
Private _dbTransaction As OleDbTransaction
'Private _dbADODBConnection As ADODB.
Public Sub New(ByVal cs As String)
_dbConnection = New OleDbConnection(cs)
_dbCommand = _dbConnection.CreateCommand
End Sub
where the connection string is:
"Provider=Microsoft.Jet.OLEDB.4.0;"
& "Data Source=" & TextEditPath.Text
texteditpath is the file path and name.
recently i have encountered an error while trying to create a relationship using "ON DELETE CASCADE" in the constraint clause.
error mentioned theres a syntax error on the constraint clause and there was no real syntax error , after troling microsoft forums , they have told me i need to use ADO connection because this bug results cause of use in DAO ,
my question is how do i establish an ADO connection to access MDB file
you can see my discussion in the ms forums here:
http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?pg=2&cat=en_us_328f8dd6-f51c-496e-93d7-5d47a17e195c&lang=en&cr=us&guid=&sloc=en-us&dg=microsoft.public.access.queries&fltr=[^]
under the title : "add constraint return syntax error"
Net
|
|
|
|
|
This is a question for the General Database forum...
Did the command line to test the command work in Access 2007 in the Immediate window??
And you're already using ADO.NET. Using DAO (really, really, really old!) never happens in VB.NET unless you go out of your way to explicitly add DAO to the project and write the code to use it.
|
|
|
|
|
yes,
in the command line the Query works
im executing the following query:
CurrentProject.Connection.Execute "ALTER TABLE Holiday ADD CONSTRAINT CalendarHoliday FOREIGN KEY ([calendarid]) REFERENCES Calendar ([id]) ON DELETE CASCADE"
although in the SQL designer window of access 2007
the following query wont work:
ALTER TABLE Holiday ADD CONSTRAINT CalendarHoliday FOREIGN KEY ([calendarid]) REFERENCES Calendar ([id])
generate same error as i get in the oleDB connector withing the .net framework:
syntax error in constrain calause
i dont know how to set a connection to the file so this query will work as it works in the immidiate window
Net
|
|
|
|
|
mistake in my post the sql in design window is:
ALTER TABLE Holiday ADD CONSTRAINT CalendarHoliday FOREIGN KEY ([calendarid]) REFERENCES Calendar ([id]) ON DELETE CASCADE
Net
|
|
|
|
|
If you want to establish an ADO connection to an Access MDB file in .NET, you will need to use COM Interop and start by setting a reference to Microsoft's ActiveX Data Objects library. This comes up often, and I guarantee if you google activex data objects "Com Interop" you will find examples.
|
|
|
|
|
hey,
I have established an ado connection and excuted the query through the connection resulted with the same error as the oleDB
i used the following code:
Public Sub adoUpdate(ByVal ct As String)
Dim con As New ADODB.Connection()
con.ConnectionString = _dbConnection.ConnectionString
con.Open()
con.Execute(ct)
con.Close()
End Sub
_dbConnection.ConnectionString contains the same connection string that i
mentioned in this thread.
im really clueless need some more help pelase ,
thanks for all the help !!!
Net
|
|
|
|
|
|
|
I m creating properties.
I M using 2 class for creating properties.
I created instant of class variable and I m trying to access but It return 0. Then How can i do.
public class Main_Class
public _CO as Double
Public Property CO() As Double
Get
Return _CO
End Get
Set(ByVal value As Double)
_CO = value
End Set
End Property
End Class
public class SubClass
Public ReadOnly Property CO1() As Double
Get
Dim uc As New Main_Class
Return uc._CO
End Get
End Property
End Class
How can Retrieve the value.
Thanks in Advance...
|
|
|
|
|
1. When you are keeping everything public, why do you even need a property?
2. Is this all the code? If yes, then you have not set any value for the variable hence it is giving 0.
|
|
|
|
|
Actually I m creating a Usercontrol.
Inside the usercontrol one is PropertyGrid control another one is Creating property(Component Property) so When i send value 20.0 but i return 0 at runtime.
And there are many more property is there. I gave one Example.
|
|
|
|
|
hello to everyone,
im new in .NET programming -and in multithreading- so if the answer of my question is to read more of multithreading just say it
i try to make an application to communicate with a device through serial port, after a lot of reading i made it to communicate in a way i want, but..... now the problem, when i use a second form, and at this form i create a thread and through that thread i try to send a data through com i get an error that com port is closed!
i try the .isAlive and in that thread the serial port looked closed.
To be more specific
IN form1 i use
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.Open()
End Sub
IN form2 i use
Imports System.Threading
Public Class Form2
Dim thr As Thread
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Debug.Print(Form1.SerialPort1.IsOpen)
thr = New Thread(AddressOf thrsub)
thr.IsBackground = True
thr.Start()
End Sub
Public Sub thrsub()
Debug.Print(Form1.SerialPort1.IsOpen)
End Sub
End Class
at the first Debug.Print(Form1.SerialPort1.IsOpen) if the Button1_click it gives TRUE but in the second Debug.Print(Form1.SerialPort1.IsOpen) in the thrsub it gives FALSE....
any suggestions?
|
|
|
|
|
I think the problem is not related to threads , it is something to do with creating proper instance of a class. When from Form2 you call Form.SerialPort1.IsOpen you are not creating an instance of Form1 which means Form1_Load never gets called , and hence the code inside the Form1_Load event is not called ,keeping the the port closed , in Form2 try this , just before Debug.Print(Form1.SerialPort1.IsOpen) statements put the following statements
Form1.Show()
Form1.Hide()
We are forcing the Form1 to load.
Let me know if this answers you question
Feel free to ask if something is not clear
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
Using the serial port instance on your Form1 instance from Form2 is bad practice. You also can't do it with the code you're written since Form2 has no idea that Form1 even exists.
If the bulk of your serial port communication is going to happen from Form2, create the port and connection on Form2, not Form1.
Also, if you dragged the SerialPort from the ToolBox onto your form, you can't use it from a second thread. The event's won't fire correctly because they depend on the main UI thread to work.
|
|
|
|
|
Hi!
i have made a component control and its inherited from System.Windows.Forms.Button class. now when i go to the designer and set the text property, i am unable to set the text property. when i set the text property and use this control on the form, that text setting is not coming. please let me know how can i get this resolution.
Thanks!
|
|
|
|
|
Without seeing your code, it's impossible to say what you did wrong.
|
|
|
|
|
i did not code anything. i have just created a component class and then went to designer partial class code and inherits it from the button class. that's it and then went to designer and tried to set the property from the property window.
|
|
|
|
|
How about this. Scrap the component you have and just add a new Class file to the project. Open that file up and replace anything you see in it with this:
Public Class MyButton
Inherits System.Windows.Forms.Button
End Class
Compile that, then drag one of these from the ToolBox to your form, then try and set the Text property.
|
|
|
|
|
hm that the way i have done too. the name of the control was "ASKButton" i have set the text property to "Add" then compile the project and drag drop the button control on the form and what i see is that the button text property is "ASkButton1". i want to set the default value for this button. when ever i drag and drop this button it should show me the Text=Add and when i want to change it, it should allow me to do so!
|
|
|
|
|
|
This has been covered all over the web countless times. All you have to do is Google a bit.
Google for "vb.net save image sql server", or whatever database engine you're using...
|
|
|
|
|
i have a string abcd 36.2 How to get the value 36.2 only , with abcd can be changed?
|
|
|
|
|
Hi
one option is that you can loop through the entire string and check for numerics
ie.
Dim x As String = "abcd 36.2"
Dim value As String = ""
For lp As Integer = 0 To x.Length - 1
If IsNumeric(x.Chars(lp)) Or x.Chars(lp) = "." Then
value &= x.Chars(lp)
End If
Application.DoEvents()
Next
MsgBox(value)
hope this helps
Anoop
|
|
|
|
|
That's the hard, slow, and non-globalized way to do it...
|
|
|
|