|
Mangore75 wrote: but nothing happen
You press F5, and then you either get an exception, or a result. If you executed the code you have now, you get a MessageBox with the text "Tables". That's because the "dt" variable contains a DataTable object with tables, and if you try to show it with a MsgBox , you'll see a .ToString() version of the object.
Click on the gutter in the right on the line that says "MsgBox" and put a breakpoint there. Run your code, and hover your mouse over the "dt" variable when the yellow line hits the breakpoint.
This code worked for me;
Imports System.Data.OleDb
Module Module1
Sub Main()
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source =""C:\Users\Eddy\Desktop\NWind.mdb""")
conn.Open()
Dim dt As DataTable
dt = conn.GetSchema("TABLES")
conn.Close()
For Each row As DataRow In dt.Rows
For Each item As Object In row.ItemArray
Console.Write(item)
Next
Console.WriteLine()
Next
Console.WriteLine(dt)
Console.ReadKey()
End Sub
End Module
It's easier if you learn it from a book.
Bastard Programmer from Hell
|
|
|
|
|
I made it your code like this but didn't work . it showed me msgbox but there is no any of name tables.
conn.Open()
Dim dt As DataTable
dt = conn.GetSchema("TABLES")
conn.Close()
For Each row As DataRow In dt.Rows
For Each item As Object In row.ItemArray
MsgBox(item.ToString)
Next
Next
MsgBox(dt.ToString)
|
|
|
|
|
Mangore75 wrote: it showed me msgbox but there is no any of name tables.
That's why I explained how to use the debugger. Seriously, put the cursor on the line that contains the MessageBox , hit the F9 key and F5 . Once the IDE shows up again, your application will be halted on the line with the breakpoint, allowing you to inspect the contents of the variable. That's a lot more effective that looking at things through a MsgBox .
On to your problem; the code should work. Download the Northwind[^]-example and test the code below (with the complete path to your database);
Dim dt As DataTable
Using con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source =""C:\Users\Eddy\Desktop\NWind.mdb""")
con.Open()
dt = con.GetSchema("TABLES")
End Using
For Each row As DataRow In dt.Rows
Console.WriteLine(row("TABLE_NAME"))
Next
Console.WriteLine()
Bastard Programmer from Hell
|
|
|
|
|
There are a couple of ways to do that. Here is some code I have, it differs from the other approach in that it doesn't use MSysObjects, instead it uses GetSchema(). As it is using C#, you may have to transpose it to your language though.
public override List<string> GetTableNames(bool all) {
using (OleDbConnection con=new OleDbConnection(connectionString)) {
con.Open();
DataTable dt=con.GetSchema("Tables");
List<string> tableNames=new List<string>();
foreach (DataRow row in dt.Rows) {
string tableName=(string)row["TABLE_NAME"];
if (!all) {
string tableNameLC=tableName.ToLower();
if (tableNameLC.StartsWith("msys")) continue;
if (tableNameLC.StartsWith("qry")) continue;
if (tableNameLC.StartsWith("query")) continue;
if (tableNameLC.StartsWith("qyr")) continue;
if (tableNameLC.EndsWith("_conflict")) continue;
}
tableNames.Add(tableName);
}
return tableNames;
}
}
This may interest you as well:
public override DataTable GetTableDescriptions() {
using (OleDbConnection con=new OleDbConnection(connectionString)) {
con.Open();
return con.GetSchema("TABLES");
}
}
And this gives you all possible information on the columns:
public DataTable GetFieldDescriptions(string tableName) {
using (OleDbConnection con=new OleDbConnection(connectionString)) {
con.Open();
return con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] {null, null, tableName, null });
}
}
|
|
|
|
|
I want to learn about Project of VB.Net.
|
|
|
|
|
Have you considered a good book? You could also try the Beginners Portal[^] on MSDN.
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: Have you considered a good book?
Reading a good book rather than learning VB.NET, good suggestion!
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Pratchett is always a good suggestion
|
|
|
|
|
you can contact me on ag99110011@gmail.com for learning vb.net programming.
ag99110011
|
|
|
|
|
|
thank's Clark for the link..
i'd love to start learning vb.net from the beginning..
|
|
|
|
|
|
Hi mates,
I have a website and my boss wants to have 3 language.
In a login page there will be a dropdown list (English,Japanese,Chinese)
after the password box.
The problem is, I don't know how to code it,
anyone have idea would be much appreciated.
They want to put in excel file.
So that they can easily add/modify a word or sentence.
I've read and search in google but result is only using
the .resx files.
Thanks in advance.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
C#Coudou wrote: I've read and search in google but result is only using the .resx files.
That's the easiest way; see the topic Multilingual content in Web Pages[^].
Making an interface to Excel will be extra work, complicating the issue. I suggest you start by introducing multilingual content, and worry about editing the languages later on.
Bastard Programmer from Hell
|
|
|
|
|
|
I am using Microsoft.Office.Interop.Excel to open, read, and write to an excel workbook in VB.net. How do I figure out if a workbook is already open?
|
|
|
|
|
Maybe this might help ...
Dim gExcelApp As New Excel.Application
Dim i As Integer
gExcelApp.Visible = True
gExcelApp.WindowState = Excel.XlWindowState.xlNormal
gExcelApp.Workbooks.Open("C:\Temp\Test.xls", , True)
For i = 1 To gExcelApp.Workbooks.Count
If (gExcelApp.Workbooks(i).Name.Equals("test.xls")) Then
Debug.Print("Already open")
End If
Next
|
|
|
|
|
Thanks David. This worked for me when the workbook was open with the current excel app. Is there a way I can find out if it is open under another excel app? Put another way, is there a way I can find all running excel apps?
|
|
|
|
|
Sounds like you want to look at other running applications on the current machine and see if they have the workbook open.
Hmmm ... sorry, I don't have an answer for you on that.
|
|
|
|
|
I would like to implement a check before / after images of the effects to which I apply, in a winform in vb.net.
some help?
overlay two images and see the other one hiding?
This is an example I wish I could play javscript in vb.net.
http://www.catchmyfame.com/2009/06/25/jquery-beforeafter-plugin/
Thanks for any response.
modified 22-Jan-12 13:15pm.
|
|
|
|
|
Assuming you have two images of identical size, I would use a Panel (of that same size) and a Scrollbar below it, then paint part of both images to the panel in its Paint handler depending on the scrollbar's value. And invalidate the Panel when the scrollbar's value gets changed. Should be straightforward.
|
|
|
|
|
paint only a portion of the image? array of pixels?
|
|
|
|
|
I suggest you read up on Graphics.DrawImage() , it is all there.
|
|
|
|
|
Thanks, it's a good start ...
|
|
|
|
|
Hi,
On 1 (office) computer I get the error
Errormessage:Invoke of BeginInvoke kan niet op een besturingselement worden aangeroepen tot de vensterkoppeling is gemaakt. bij System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle waitHandle) bij System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) bij System.Windows.Forms.Control.Invoke(Delegate method, Object[] args) bij System.Windows.Forms.Control.Invoke(Delegate method) bij Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.HideSplashScreen() bij Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.MainFormLoadingDone(Object sender, EventArgs e) bij System.EventHandler.Invoke(Object sender, EventArgs e) bij System.Windows.Forms.Form.OnLoad(EventArgs e) bij System.Windows.Forms.Form.OnCreateControl() bij System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) bij System.Windows.Forms.Control.CreateControl() bij System.Windows.Forms.Control.WmShowWindow(Message m) bij System.Windows.Forms.Control.WndProc(Message m) bij System.Windows.Forms.ScrollableControl.WndProc(Message m) bij System.Windows.Forms.ContainerControl.WndProc(Message m) bij System.Windows.Forms.Form.WmShowWindow(Message m) bij System.Windows.Forms.Form.WndProc(Message m) bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message m) bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message m) bij System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
on starting the program. The second time I start the program it works fine.
Has someone an idee what this all means? and how to solve it
On my own pcs it works fine
Jan
|
|
|
|