|
Cory Kimble wrote: I could not find anything on google or Code Project that has all I want.
I also did a quick search on Google and quickly found the following articles:
Get table names for MS Access database[^]
Get table names for SQL Server database[^]
They should get you started.
Cory Kimble wrote: I need vb.net code to get table names for Access and Sql server databases.
Generally speaking, it isn't considered polite to ask for code without having made a serious attempt to solve the problem yourself. I suggest that you look at the above article, try and solve the problem yourself and post again in you encounter any further difficulties.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
The article you suggested is for C# I need for VB.net
|
|
|
|
|
Cory Kimble wrote: The article you suggested is for C# I need for VB.net
So convert it. There are plenty of tools available online to do this. Alternatively, learn C#.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
How do I add args to System.Timers.ElapsedEventArgs? For example, I have a process running and after an elapsed time I want to pass its process.id to my TimerElapsed handler. I'm a bit of a newbie, but don't be gentle with me
Many thanks to any who take the time to answer...
R
|
|
|
|
|
You can't change an existing class, you can derive a class from this one, but you can't make the event use it. You need to find another way of passing this value, probably using your own delegate.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian. This has turned out to be surprisingly complicated. Surely others are passing something into their timer event handlers other than the fact that "time's up", I've got a perfectly good bar-tender for that.
At present my lack of ability has me stuck between two cludges;
1. System.Threading.Thread.Sleep and let the rest of my WinService wait (which it can't, life's too short), or
2. Instantiate a timer before I even know whether there's an issue with any of the processes I'm interested in, then look for the pids at the other end. Yuk!
This has to have been done before?
R
|
|
|
|
|
Hi,
what you can do with a timer, you probably can also do with an extra thread and indeed
a Thread.Sleep; that way the existing threads continue as before, and the new thread can,
posibly executing within its own class, hold and keep whatever information and state you
want it to have.
there may be and probably are more elegant approaches to what you need, but then I would like
to better understand what it is you want to achieve.
|
|
|
|
|
And now I see threading lets me pass in the pid as an object...
Dim myParamThread As New Thread(AddressOf myParamHandlerThread)<br />
myParamThread.Start(CType(p.id, Object))<br />
<br />
Private Sub paramHandlerThread(ByVal obj As Object)<br />
Dim Proc As Process = Process.GetProcessById(CType(obj, Integer))<br />
Sleep(interval)' then do stuff<br />
End Sub<br />
<br />
Thanks.
|
|
|
|
|
I'm sure it can be done, but not in the way you're suggesting. You cannot add to an existing event args class, and you cannot change which class the framework uses to fire an event.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian and Luc,
First real coding I've done since VB6, hadn't realised creating a new thread was quite so easy, though I still can't pass in an argument. Will cludge sth as follows while I continue getting my head round delegates and such.
Dim myProc1Thread as new Thread(AddressOf Proc1Handler)<br />
myProc1Thread.IsBackground=True<br />
myProc1Thread.Start()<br />
<br />
Private Sub Proc1Handler()<br />
Dim Processes As Process() = Process.GetProcessesByName("processName")<br />
If Processes.Length > 0<br />
System.Threading.Thread.Sleep(interval)<br />
For Each p As Process In Processes<br />
If Not p.HasExited Then<br />
'Do something<br />
...<br />
Thanks again,
R
|
|
|
|
|
Realised u cant install the Windows platform SDK on XP service Pack 2
am planning on a TAPI Videoconferencing software with VB.NET and all teh TAPI and AVP cAPTURE DLLS
Do i need to start using Windows Server to be able to instatll and use the Platform SDK or i can succesfuuly build ma applicaion using Windows XP..
tHANKS IN advance.
phatkin
|
|
|
|
|
prubyholl wrote: Realised u cant install the Windows platform SDK on XP service Pack 2
Really? It worked fine for me and thousands of other people. What's the error you're getting??
|
|
|
|
|
I need to Export data in a Gridview to Excel file, please any body help...
I tried a lot but could'nt make it.
The application is made in VB.NET standalone (NOT web based)
I have a gridview with data, i need to export it to .xls or .csv file
please help...
Jats
|
|
|
|
|
Don't cross post. You already posted this same question in the article I would have pointed you at. If you can't read the article and code in it and understand what it does, noone is going to be able to explain the process to you in a much shorter forum post that will offer nowhere near as much explanation.
If you want other examples you can try, Google for "VB.NET export data to Excel".
|
|
|
|
|
Sorry for cross posting. But the code project page was showing error when i posted in the article.
So i posted here again.
May be the CodeProject site is not working properly. I suppose.
By the way i read the article and understood very well but i have no knowledge of C# so hoping some body can help me.
Jats
|
|
|
|
|
Jats_4ru wrote: but i have no knowledge of C#
BS. You know more than you think you do. Take a look at a bunch of documentation in the MSDN Help for Visual Studio. Notice that there are thousands of examples of small bits of code in both C# AND VB.NET. Compare the two and you'll find C# has a lot in common with VB. Most of what you see has nothing to do with either language anyway since alot of code just manipulates objects in the .NET Framework.
For example, these two pieces out of the MSDN docs on the ManagementObjectSearcher class are, line-for-line, identical:
' VB.NET
Imports System
Imports System.Management
Public Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
Dim s As New ManagementObjectSearcher( _
"root\MyApp", _
"SELECT * FROM Win32_Service", _
New EnumerationOptions( _
Nothing, System.TimeSpan.MaxValue, 1, _
True, False, True, True, False, _
True, True))
For Each service As ManagementObject In s.Get()
'show the instance
Console.WriteLine(service.ToString())
Next
End Function
End Class
using System;
using System.Management;
public class Sample
{
public static void Main(string[] args)
{
ManagementObjectSearcher s =
new ManagementObjectSearcher(
"root\\CIMV2",
"SELECT * FROM Win32_Service",
new EnumerationOptions(
null, System.TimeSpan.MaxValue,
1, true, false, true,
true, false, true, true));
foreach (ManagementObject service in s.Get())
{
Console.WriteLine(service.ToString());
}
}
}
All you have to do is compare each line to see that they both specify the exact same things, just using a slightly different syntax.
|
|
|
|
|
Don't cross post. It's just plain rude.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
i am using .net 2005.i do my project in vb.net windows application.i want to calculate the date for one year.
for (ex)
example-1:
i have 2 date time picker,in first datetimepicker i click 12-14-2007 means,then automatically displayed as 12-13-2008 in second datetimepicker.
example-2:
i have 2 date time picker,in first datetimepicker i click 08-20-2007 means,then automatically displayed as 08-19-2008 in second datetimepicker.
that means i want to calculate one year from i selected date in leap year and without leap year.
|
|
|
|
|
DateTime.Now.AddDays(-1).AddYears(1)
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
I m trying to create a crystal report in vb.net application.
I need to show data from 3 different tables in report.
So i added all 3 tables in Field explorer of crystal report,but i m unable to show the data in it.
For this i have tried two method:-
1>Using joning add data in a single table and set the Datasource of the report to it something like this-
<br />
<br />
Dim rpt As New CrystalReport1<br />
rpt.SetDataSource(MyDataset.Tables(0))<br />
Me.CrystalReportViewer1.ReportSource = rpt<br />
<br />
2>Without joining using two tables for it like this<br />
i)Select data from 1 table<br />
MySqlDataAdapter.Fill(MyDataset, "Table1")<br />
ii)Select data from 2 table<br />
MySqlDataAdapter.Fill(MyDataset, "Table2")<br />
<br />
iii)Select data from 3 table<br />
MySqlDataAdapter.Fill(MyDataset, "Table3")<br />
<br />
Dim rpt As New CrystalReport2<br />
rpt.SetDataSource(MyDataset)<br />
Me.CrystalReportViewer1.ReportSource = rpt<br />
But nothing happened
Any idea would be appreciated heartly
Thanks with anticipation
|
|
|
|
|
First: is you'r dataset filled??
second: in design vieuw of the report (at the bottom of the screen 'main report preview' is there data??
and third you could try the code below, this code will reconnect you'r report with you'r database.
And if you created the report with the tables in field explorer and such you don't even need to set the reportsource when using this code
<br />
Dim rpt As New crystalreport<br />
rpt = reconnectreport(rpt)<br />
<br />
<br />
Private Function reconnectreport(ByVal report As ReportDocument) As ReportDocument<br />
Dim connection As IConnectionInfo<br />
Dim oldServerName As String = report.DataSourceConnections(0).ServerName<br />
Dim newServerName As String = sservername<br />
Dim oldDatabaseName As String = report.DataSourceConnections(0).DatabaseName<br />
Dim newDatabaseName As String = sdbname<br />
Dim userID As String = susername<br />
Dim password As String = spass<br />
report = report<br />
' Change the server name and database in main reports<br />
For Each connection In report.DataSourceConnections<br />
If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
' SetConnection can also be used to set new logon and new database table<br />
report.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
newServerName, newDatabaseName, userID, password)<br />
End If<br />
Next<br />
' Change the server name and database in subreports<br />
Dim subreport As ReportDocument<br />
For Each subreport In report.Subreports<br />
For Each connection In subreport.DataSourceConnections<br />
If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
' SetConnection can also be used to set new logon and new database table<br />
subreport.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
newServerName, newDatabaseName, userID, password)<br />
End If<br />
Next<br />
Next<br />
Return report<br />
End Function<br />
hope it was helpfull
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
Respect TDDragon
First of all thanks a lot for having look at my post & reply and second sorry for late
As U said i checked all things
1>The dataset is full of data
2>In design view the report shows dummy data in preview report
3>I used your code but i m little confuse boz in your code where i should use the dataset (U used database)?
<br />
Private Sub print_me()<br />
Try<br />
Dim sql As String = ""<br />
Me.cnn.Open()<br />
' sql=Query<br />
ad = New SqlDataAdapter(sql, cnn)<br />
ad.SelectCommand.CommandType = CommandType.Text<br />
Me.ds = New DataSet<br />
ad.Fill(ds)<br />
Me.cnn.Close()<br />
<br />
Dim rd, new_rd As New CrystalDecisions.CrystalReports.Engine.ReportDocument<br />
rd.Load(Application.StartupPath + "\CrystalReport1.rpt")<br />
<br />
rd.SetDataSource(Me.ds)<br />
new_rd = Me.reconnectreport(rd)<br />
<br />
Catch ex As Exception<br />
MessageBox.Show(ex.ToString, "Crystal", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
Me.cnn.Close()<br />
End Try<br />
End Sub<br />
<br />
Private Function reconnectreport(ByVal report As CrystalDecisions.CrystalReports.Engine.ReportDocument) As CrystalDecisions.CrystalReports.Engine.ReportDocument<br />
Dim rpt As New CrystalReport1<br />
rpt = reconnectreport(rpt)<br />
<br />
Dim connection As CrystalDecisions.Shared.IConnectionInfo<br />
Dim oldServerName As String = report.DataSourceConnections(0).ServerName<br />
Dim newServerName As String = "SYSTEM2"<br />
Dim oldDatabaseName As String = report.DataSourceConnections(0).DatabaseName<br />
Dim newDatabaseName As String = "xcpa"<br />
Dim userID As String = "sa"<br />
Dim password As String = ""<br />
report = report<br />
' Change the server name and database in main reports<br />
For Each connection In report.DataSourceConnections<br />
If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
' SetConnection can also be used to set new logon and new database table<br />
report.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
newServerName, newDatabaseName, userID, password)<br />
End If<br />
Next<br />
' Change the server name and database in subreports<br />
Dim subreport As CrystalDecisions.CrystalReports.Engine.ReportDocument<br />
For Each subreport In report.Subreports<br />
For Each connection In subreport.DataSourceConnections<br />
If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
' SetConnection can also be used to set new logon and new database table<br />
subreport.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
newServerName, newDatabaseName, userID, password)<br />
End If<br />
Next<br />
Next<br />
Return report<br />
End Function<br />
But it gives error that:-
An unhandled exception of type System.StackOverflowException' occurred in CrystalDecisions.CrystalReports.Engine.dll
I think i have missed something
Thanks a lot once again
|
|
|
|
|
the reconnectreport function only reconnects your report to the database so it doesn't set the datasource
best practice is too reconnect the report first and then set the datasource (if needed)
~V~ wrote: rd.SetDataSource(Me.ds)
new_rd = Me.reconnectreport(rd)
becomes:
new_rd = me.reconnectreport(rd)
new_rd.setdatasource(me.ds)
wether or not you need to set the datasource depends on how you designed your report.
If you designed it against a real database using the table structure and such and you don't need to add additional filters then you shouldn't have to set the datasource but if you do need to add additional filters it is somethimes easer to set the datasource with a new sql statement.
example:
you have a report that connects to 2 tables (table1 and table2)
all you want to do is to show the data from the 2 tables without filters
in this case you don't need to do the setdatasource
if you want to show only one record from table1 and the corresponding records from table2
you'd best set the datasource for table1 and table2 in code
On a side note: make sure that the database name,server,username,password you provide in the reconnect function are correct (I suspect you placed dummy data here (as you should)). If these are wrong the report will not connect to the database and most likly crash.
Sorry for the late reply but I was out for the weekend so...
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
Any help would be appreciated
|
|
|
|
|
Sorry to trouble u
But i m facing the same problem after changed the line as u told me
<br />
Private Sub print_me()<br />
Try<br />
Dim sql As String = ""<br />
Me.cnn.Open()<br />
sql = "select a.srno,a.amount,c.name,b.h_name from satrans as a inner join hor as b on a.h_id=b.h_id inner join party as c on a.party_id=c.party_id where a.match_id = 1"<br />
<br />
ad = New SqlDataAdapter(sql, cnn)<br />
ad.SelectCommand.CommandType = CommandType.Text<br />
Me.ds = New DataSet<br />
ad.Fill(ds)<br />
Me.cnn.Close()<br />
<br />
Dim rd, new_rd As New CrystalDecisions.CrystalReports.Engine.ReportDocument<br />
rd.Load(Application.StartupPath + "\CrystalReport1.rpt")<br />
<br />
new_rd = Me.reconnectreport(rd)<br />
rd.SetDataSource(Me.ds)<br />
<br />
Catch ex As Exception<br />
MessageBox.Show(ex.ToString, "Crystal", MessageBoxButtons.OK, MessageBoxIcon.Error)<br />
Me.cnn.Close()<br />
End Try<br />
End Sub<br />
<br />
<br />
Private Function reconnectreport(ByVal report As CrystalDecisions.CrystalReports.Engine.ReportDocument) As CrystalDecisions.CrystalReports.Engine.ReportDocument<br />
<br />
Dim rpt As New CrystalReport1 '### The error occured here<br />
rpt = reconnectreport(rpt)<br />
<br />
Dim connection As CrystalDecisions.Shared.IConnectionInfo<br />
Dim oldServerName As String = report.DataSourceConnections(0).ServerName<br />
Dim newServerName As String = "SYSTEM2"<br />
Dim oldDatabaseName As String = report.DataSourceConnections(0).DatabaseName<br />
Dim newDatabaseName As String = "xcpa"<br />
Dim userID As String = "sa"<br />
Dim password As String = ""<br />
report = report<br />
' Change the server name and database in main reports<br />
For Each connection In report.DataSourceConnections<br />
If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
' SetConnection can also be used to set new logon and new database table<br />
report.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
newServerName, newDatabaseName, userID, password)<br />
End If<br />
Next<br />
' Change the server name and database in subreports<br />
Dim subreport As CrystalDecisions.CrystalReports.Engine.ReportDocument<br />
For Each subreport In report.Subreports<br />
For Each connection In subreport.DataSourceConnections<br />
If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
' SetConnection can also be used to set new logon and new database table<br />
subreport.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
newServerName, newDatabaseName, userID, password)<br />
End If<br />
Next<br />
Next<br />
Return report<br />
End Function <br />
Error is:-
<u>An unhandled exception of type System.StackOverflowException' occurred in CrystalDecisions.CrystalReports.Engine.dll</u>
Thanks once again
modified on Wednesday, December 19, 2007 6:13:21 AM
|
|
|
|
|