|
hi priya,
see this code I hope it will give some idea about mysql+ado.net using Vb.net
Dim connectionString As String = "Driver={MySQL};SERVER=localhost;DATABASE=NorthwindMySQL;"
Or you can use an ODBC DSN, as you can see from the following code that I've used TestDSN DSN to connect to the data source:
Dim conn As New OdbcConnection("DSN=TestDSN")
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim connectionString As String = "Driver={MySQL};SERVER=localhost;DATABASE=NorthwindMySQL;" '
Dim conn As New OdbcConnection(connectionString)
conn.Open()
Dim da As New OdbcDataAdapter("SELECT CustomerID, ContactName, ContactTitle FROM Customers", conn)
Dim ds As New DataSet("Cust")
da.Fill(ds, "Customers")
dataGrid1.DataSource = ds.DefaultViewManager
conn.Close()
End Sub
WINNING IS NOT OUR DREAM,IT'S A HABIT
HAVE A NICE EVENING
|
|
|
|
|
hi dornala,
Thank u so much for ur help.
i write as u given , i didnt get any error but data is not displayed in datagridview.
i put MsgBox(ds.Tables(0).Columns(0).ColumnName) it is showing columnName it means data is there is ds(dataset) but not seen on datagridview(DgvCustList)
will u give me wht to do plizzzz.....
Dim connectionString As String = "User Id=root; Password=root; Host=jupitor;port=3306;Database=timesheet;"
Dim conn As New MySqlConnection(connectionString)
conn.Open()
Dim da As New MySqlDataAdapter("SELECT custid,custcode,custname FROM cust_mast;", conn)
Dim ds As New DataSet("Cust")
da.Fill(ds, "cust_mast")
DgvCustList.DataSource = ds.DefaultViewManager
MsgBox(ds.Tables(0).Columns(0).ColumnName)
conn.Close()
-- modified at 8:33 Wednesday 17th January, 2007
-- modified at 8:34 Wednesday 17th January, 2007
priya
|
|
|
|
|
a DgvCustList.databind() should solve your issue.
You can only be young once. But you can always be immature.
- Dave Barry
|
|
|
|
|
I am using VB.NET with Ms Access and Ms Excel, how can i diplay Table name or amount of sheets,
Socheat
................
|
|
|
|
|
Socheat,
MS Access is different from excel.
Excel Using OLE connection:
Public Class XcelFileReader
Const testStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source={0};" & _
"Extended Properties=""Excel8.0;HDR=No;IMEX=1"""
'NOTE: Imex =1 Reads all value as typeof(string)
Protected Sheets As ArrayList
Protected cCon As OleDbConnection
Public Sub New(ByVal file As String)
cCon = New OleDbConnection(String.Format(testStr, file))
Sheets = New ArrayList()
Try
cCon.Open()
System.Diagonstic.Debug.WriteLine(cCon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,Nothing).Rows.Count.Tostring())
Finally
If cCon.State <> System.Data.ConnectionState.Closed Then cCon.Close()
End Try
End Sub
End Class
You can only be young once. But you can always be immature.
- Dave Barry
|
|
|
|
|
I have just upgraded a Visual Studio 2002 Windows application project to Visual Studio 2005, including upgrading to the latest custom controls.
The compiled application runs fine but on exit I get a windows message box with my application's title in the title bar and the message:
The exception unknown software exception (0xc0020001) occurred in the application at location 0x7c812a5b
This happens after the last line of code has run so as a total guess it's something to do with garbge collection.
Then I run in the Visual Studio 2005 environment I don't get this error (or any others).
The application uses Crystal Reports, Dundas, Devexpress and Infragistics controls.
My only lead so far is that if I get the application to display on screen one of the Crystal reports then the error doesn't happen on closedown. I'm looking through this code to see what I can see but there's quite a lot of code and I don't know what I'm looking for.
Any help welcome.
- Ben
|
|
|
|
|
I wrote a code in VB.NET which accesses the outlook folders.Following is the code.According to this code it displays outlook folders and there is hyperlink on each subject.I want when we click on the subject the message body should be dispalyed.in href how can we do this? I know we have to write a function to dispalay the body.but i don't know how to do this?can u please tell me ?
an exception Invalid cast exception is coming in this line
oMsg = oItems.Item(i)
it means when we access the folders and suppose the folder contains a calender meeting items i.e. another cast or datatype then the inner loop stops executing.
please tell me to handle this exception?
code is like this
we ahve to add a refernce Microsoft outlook 11.0 library from Project->add reference -> COM tab and the code is this please help me?
Imports System.Runtime.InteropServices
Imports
Microsoft.Office.Interop.Outlook
Imports
System.IO
Module
Module1
Sub Main()
'OlSecurityManager.DisableOOMWarnings = True
Try
' Create Outlook application.
Dim app As Microsoft.Office.Interop.Outlook.Application = New Microsoft.Office.Interop.Outlook.Application
' Get NameSpace and Logon.
Dim appNameSpace As Microsoft.Office.Interop.Outlook.NameSpace = app.GetNamespace("MAPI")
appNameSpace.Logon("Outlook", "bhavna123",
False, True)
' Get Messages collection of Inbox.
Dim fs As New FileStream("c:\Outlook_Folders.htm", FileMode.Create, FileAccess.Write)
Dim s As New StreamWriter(fs)
Dim oPFolder As Microsoft.Office.Interop.Outlook.MAPIFolder = appNameSpace.Folders.GetFirst()
Dim oFol As Microsoft.Office.Interop.Outlook.Folders = oPFolder.Folders
Dim sfolder As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim j As Integer
For j = 1 To oFol.Count
sfolder = oFol.Item(j)
s.WriteLine("")
s.WriteLine(sfolder.Name)
s.WriteLine("")
s.WriteLine("")
Dim oItems As Microsoft.Office.Interop.Outlook.Items = sfolder.Items
Dim oMsg As Microsoft.Office.Interop.Outlook.MailItem
Dim i As Integer
For i = 1 To oItems.Count
Try
oMsg = oItems.Item(i)
s.WriteLine("- ")
s.WriteLine("" + oMsg.Subject + "")
s.WriteLine(" ")
Catch ex As InvalidCastException
Console.WriteLine("Caught:InvalidCastException", ex)
'Ignore any invalid casts.
End Try
Next
s.WriteLine(" ")
s.WriteLine("")
Next
s.Close()
fs =
New FileStream("c:\Outlook_Folders.htm", FileMode.Open, FileAccess.Read)
Dim d As New StreamReader(fs)
d.BaseStream.Seek(0, SeekOrigin.Begin)
'LogOff
appNameSpace.Logoff()
'cleanup
app =
Nothing
appNameSpace =
Nothing
'oItems = Nothing
Console.ReadLine()
Catch exc As ApplicationException
Console.WriteLine("Caught:ApplicationException", exc)
'Finally
' OlSecurityManager.DisableOOMWarnings = False
End Try
End Sub
End
Module
|
|
|
|
|
Hi.
How do I search anything in datasets or datatables? Are there any methods for this?
WofR
|
|
|
|
|
By searching, I assume you are referring to searching records.
If so then,
Dataset - Cannot really search records in a collection of datatables!
Datatable - you can create a view out of it and apply a filter on it.
Shreekar
|
|
|
|
|
You can create a BindingSource if you haven't already and do the following:
MyBindingSource.Position = MyBindingSource.Find("Column Name",Key) Where key is the primary key value of the record you require.
This code will cause the BindingSource to jump to the specified method, if you don't want to jump, don't set the .Position property. The .Find property returns an index to the BindingSource's list.
you can't forget something you never knew...
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
Depending on what you are doing the DataSet.Select(string) function can be usefull. Where String is the where clause of a SQL Statement, AND not to terribly complicated.
You can only be young once. But you can always be immature.
- Dave Barry
|
|
|
|
|
:-DHow to connect excel databse in VB or VB.net
raviuday
|
|
|
|
|
Google has the answer.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Const testStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source={0};" & _
"Extended Properties=""Excel 8.0;HDR=No;IMEX=1"""
You can only be young once. But you can always be immature.
- Dave Barry
|
|
|
|
|
Sir/Madam,
I am facing a problem in implementing a query in vb.net.
I have two tables.
named table1 , table2
I have to pick those records from table1 which are not present in table2.
Id is primary in table1 and foreign in table2
For that i am using the following query.
SELECT table1.Id
from
table1,table2
where
table1.Id<>table2.id
Please help.
Thanks and Regards
Pankaj
-- modified at 4:01 Wednesday 17th January, 2007
|
|
|
|
|
Make a left join on the second table. Where there are no record in the second table, the values will be null, so you can select the records where the key from the second table is null.
select ...
from table1 as t1
left join table2 as t2 on t2.id = t1.id
where t2.id is null
---
Year happy = new Year(2007);
|
|
|
|
|
Sir,
If I have four tables , named table1 , table2 , table3 , table4.
and I have to pick those records from table1,table2,table3 , which are not present in table4.
Then the same query is not working
I am doing in the following way.
select t1.Contact_Id
from tblConact_Master as t1,tbl_Contact_Address as t3
left join tblrcdetail as t2 on (t2.Contact_id = t1.Contact_Id and t2.contact_id = t3.Contact_Id)
where t2.Contact_id is null
Please help.
Thanks and regards
Pankaj
-- modified at 4:33 Wednesday 17th January, 2007
|
|
|
|
|
select table1.contact_id
from table1, table2, table3
where table1.contact_id = table2.contact_id and
table1.contact_id = table3.contact_id and
table1.contact_id not in (select contact_id from table4)
|
|
|
|
|
I'm going out on a limb with this one, but I was wondering if there is a simple way to do global error handling?
Meaning, for all errors that my code, fails to capture, a certain segment of code is executed. This will then report the error to me via email or a DB entry etc.
If this is not possible it will mean that my program has to have emaculate error handling, which, in this case, is easier said than done.
(VB.Net 2005)
you can't forget something you never knew...
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
Sure there is but it may not always prove to be user friendly.
For WinForms...
One of the new features of VB.NET 2005 is the ability to specify code to run when your app encounters an unhandled exception. You can set this up by going into the code editor of the Application.Designer.vb file & writing or referencing code for the MyApplication_UnhandledException event. By default the Application.Designer.vb file is hidden & it is not recommended to modify it directly but this is the only way I know to set this up.
You can also get all information regarding the exception (including stack trace, etc.) from the EventArgs passed to the handler.
I wouldn't recommend this to be the only way you handle errors in your code tho. It's a nice feature but not a replacement for good coding & planning.
For WebApps...
What I usually do is set it up using a Global.asax file. The Global.asax file has an Application_Error event handler that handles any errors that occur in your web app. You can log these errors using the Server.GetLastError() method & then redirect the user to a custom error page or whatever.
Hope that helps.
|
|
|
|
|
Yes, you can put a try catch at the top level, and also there are two events you can subscribe to ( forget what they are right now ), then you can write whatever code you like. My release apps always catch all exceptions and generate a log, it's indispensible when you have issues on a client machine only.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
how can I create a vertical label in VB6
Hello Friends
|
|
|
|
|
Make a normal label, then turn your screen on it's side
I couln't find any other way! Perhaps you can download a vertical font and use an array of labels to display single letters below one-another?
you can't forget something you never knew...
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
Can I make a Crystal Report using dataview?
Suman
|
|
|
|
|
I am Developing the software for consultancy. The main theme of project is to automate whole recruiters process. Ex:- Usually the recruiter logon into their Website, download the resume and verify whether its matching for their clients Requirements or not. If its matching then only they Forward it. This is the major process.
"Resume Sourcing" is a module in my project. In that, I want to fetch all the fields from the resume like:
Candidate Name , Date of Birth , Father’s Name , Contact , Details/Address , City , Location , Contact No. , Phone (Rest) , Mobile No. , E-Mail ID , Languages Known , Passport No. , Gender , Martial Status , Alternate E-mail ID , Resume Title , Objective , Summary , Total Years of Experience , Area of Interest , Current organization , From Date , To , Date , Company Name , CTC , Training Undergone , Current Industry Type , Current Functional Area , Role , Total Expertise , Level of Current Organization
I want to gather information from the resume in any format like .doc, .rtf, .htm
Plz give me suggestions and guidence to success the module.
Thanks & Regards
-- modified at 2:54 Wednesday 17th January, 2007
-- modified at 2:56 Wednesday 17th January, 2007
Kumaran
|
|
|
|
|