|
Change it to this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim mcnConn As OleDbConnection
Dim mdsDSet As New DataSet
Dim mcmCurMang As CurrencyManager
Dim mvueDatVue As DataView
Dim mdaAdapter As OleDbDataAdapter
Dim strConnectionString As String
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=DUBookstore2000.mdb"
mcnConn = New OleDbConnection(strConnectionString)
Dim strSQLStatement As String
strSQLStatement = "SELECT Name FROM Publishers"
mdaAdapter = New OleDbDataAdapter(strSQLStatement, mcnConn)
mdaAdapter.Fill(mdsDSet, "Publishers")
mvueDatVue = New DataView(mdsDSet.Tables("Publishers"))
Me.cboComboBox.DataSource = mvueDatVue
Me.cboComboBox.ValueMember = "Name"
'mcmCurMang = CType(Me.BindingContext(mvueDatVue), CurrencyManager)
End Sub
progload
|
|
|
|
|
Thanks, that helped! Unfortunately though, now that has led me to another problem. The sub above is from an application that uses textboxes to display individual fields from an Access table. There is no grid on the form, each record is displayd via the textboxes along with one combobox (which displays a particular book's publisher). There are two buttons on the form to let the user go forward or backward through the individual records on the form. Pretty striaghtforward stuff.
The problem I'm running into now is that, since that combobox is populated, it is simply populated with a list of publishers that are displayed as one would move through the record set. Like this....here's what the combo box should display:
Company A
Company B
Company C
Company D
Okay. Let's say there are 24 records in the table in the Access database. Right now, that combo box is showing this:
Company A
Company D
Company D
Company C
Company A
Company B
.....
and so on, depending on what book is linked to what publisher, as we go through the records. So, how can I tweek that code above to show a non-repeating list of the publishers? Thanks in advance.
-Steve
|
|
|
|
|
Change your SQL statement to:
strSQLStatement = "SELECT DISTINCT Name FROM Publishers ORDER BY Name"
|
|
|
|
|
That didn't really change anything. Let me post a little more code:
This is my sub to bind the textboxes and that combobox.
Private Sub BindData()
'**********************************
'Purpose: Binding the labels, txtboxes, and
'comboboxes on the form to the data
'
'Outputs: Bound display controls to the data and the currency manager
'
'Author: Steve Swanson
'Date: July 26, 2004
'
'**********************************
Dim strSQLPublishers As String = "SELECT DISTINCT Name FROM Publishers"
Try
'create a list of publisher Name's based on PublisherID
mdaPublishers = New OleDbDataAdapter(strSQLPublishers, mcnDuBookstore2000)
mdaPublishers.Fill(mdsDuBookstore2000Books, "Publishers")
cboPublisher.DataSource = mvueDuBookstore2000
cboPublisher.ValueMember = "Name"
'bind the txtboxes on the form to the corresponding columns in the
'DUBookstore2000.mdb database
Me.lblBookID.DataBindings.Add("Text", mvueDuBookstore2000, "BookID")
Me.txtTitle.DataBindings.Add("Text", mvueDuBookstore2000, "Title")
Me.txtAuthorName.DataBindings.Add("Text", mvueDuBookstore2000, "AuthorName")
Me.cboPublisher.DataBindings.Add("Text", mvueDuBookstore2000, "Name")
Me.txtPrice.DataBindings.Add("Text", mvueDuBookstore2000, "Price")
Me.txtBooksOnHand.DataBindings.Add("Text", mvueDuBookstore2000, "BooksOnHand")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
'use the currency manager to control the iteration through the rows
'in the database
mcmDuBookStore2000Books = CType(Me.BindingContext(mvueDuBookstore2000), CurrencyManager)
End Sub
Hope this helps, I can post more if needed.
|
|
|
|
|
Try it again, you forgot the last part of the sql statement:
strSQLStatement = "SELECT DISTINCT Name FROM Publishers ORDER BY Name"
|
|
|
|
|
Hello!
This is my code. My Datagrid populates all null values.I need help to populate the Datgrid
Thanks
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim myConnectionString As String = "user id=dbusdev;data source=DBUSDV"
Dim oracleconnection1 As New OracleClient.OracleConnection(myConnectionString)
oracleconnection1.Open()
Dim OracleDataAdapter1 As New OracleClient.OracleDataAdapter(" SELECT * FROM TPROFILE", oracleconnection1)
Dim DataGrid1 As New DataGrid
Dim DataSet1 As DataBase.DataSet1
DataSet1 = New DataBase.DataSet1
OracleDataAdapter1.Fill(DataSet1)
DataGrid1.DataSource = DataSet1
DataGrid1.DataMember = "DataSet1.TPROFILE"
DataGrid1.SetDataBinding(DataSet1, "DataSet1.TPROFILE")
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
oracleconnection1.Close()
End Try
dnagpaul
|
|
|
|
|
Hello everyone. I need help w/ textboxes to update an Access database. For a first name textbox, I have the following code to update the changed text.
Private Sub txtClientFirstName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtClientFirstName.TextChanged
Dim commandBuilder As New OleDb.OleDbCommandBuilder(dataAdapter)
dt.Rows(rowIndex)("First_Name") = txtClientFirstName.Text
Try
commandBuilder.DataAdapter.Update(dt)
'dataAdapter.Update(dt)
'commandBuilder.Dispose()
'dataAdapter.Dispose()
Catch exp As InvalidOperationException
End Try
This code will allow the user to alter the contents of the text box, but it will not move those changes to the database. What am I doing wrong?
|
|
|
|
|
Hello!
This is my code. My Datagrid populates all null values.I need help to populate the Datgrid
Thanks
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim myConnectionString As String = "user id=dbusdev;data source=DBUSDV;password=dbusdev"
Dim oracleconnection1 As New OracleClient.OracleConnection(myConnectionString)
oracleconnection1.Open()
Dim OracleDataAdapter1 As New OracleClient.OracleDataAdapter(" SELECT * FROM TPROFILE", oracleconnection1)
Dim DataGrid1 As New DataGrid
Dim DataSet1 As DataBase.DataSet1
DataSet1 = New DataBase.DataSet1
OracleDataAdapter1.Fill(DataSet1)
DataGrid1.DataSource = DataSet1
DataGrid1.DataMember = "DataSet1.TPROFILE"
DataGrid1.SetDataBinding(DataSet1, "DataSet1.TPROFILE")
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
oracleconnection1.Close()
End Try
dnagpaul
|
|
|
|
|
did you try to directly update the text boxes with something like:
txtTextBoxName.text = CStr(datagrid1(rowIndex)("Databasse_column_Name"))
where rowIndex is an integer defined in either globally or in your sub-function.
|
|
|
|
|
No.I did not use Text Boxes. Using the property of DataAdapter and "preview Data" and the "Fill DataSet" seems to populate it ........
Thanks
Dolly
|
|
|
|
|
I got it to work........
Thanks
|
|
|
|
|
I'm using vb.net to develop windows and web applications, and I need a really good datagrid. I need to be able to colorize individual cells, have a variety of columnStyles, and hopefully have the ability to drill though an OLAP cube(but not absolutely necessary)
I've been looking at FarPoint, ComponentOne, and Exceed. Can anyone make a recomendation as to what they think is the best? easiest to program? contains the most features, etc?
Thanks
Chris
Internal Software Developer
|
|
|
|
|
|
I have a VB 6.0 DLL application (not .NET) that monitors an FTP directory at a specific interval. When a file gets place in the directory the DLL then moves it to another location and puts it under configuration Management control. This all seems to work fine.
Recently though the files being transferred from an AIX system to the NT system are becoming quite large, approx 20Mb. My problem is that the monitoring of a file in the FTP directory can coincide with a file actually appearing. This can then cause the scenario where the file is being moved from the FTP directory before the FTP copy has completed, and therefore I get files where the size is seriously reduced. Since these files are Zip files it means that I then get a corruption error when I try to unzip the files.
Is there any way that I can check to ensure that a file is not in the middle of being copied before I move it.
I noticed that there was a MoveFileEx Win32 API where you can state that the move function will only complete once the file has been successfully transferred, but that doesn't really help me out here as the file is coming from an AIX box and not from another NT directory.
Simes
|
|
|
|
|
You have to make sure that your FTP Server software support file locks during an upload. You can test this by trying to open the file in your app while it is being uploaded, using Deny Share Read and Deny Share Write. If your able to open the file while it's being uploaded, there is no way you can determine when the transfer from the AIX box has completed.
You'll have to write your own copy function that supports reading a file to the end and writing whatever it finds, then it should sit there and wait until more data shows up, then copy the new chunk of the file. But, the trick is to wait a specified time from the last chunk of data that was read. When that timeout finally occurs, say 1 minute with no new data showing up, your code should assume that the file transfer is complete, then close the files and return.
I hope I explained everything OK...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I was just wondering if anyone could quickly knock up an app that knows when a stupid person has sat infront of my software. What i need it to is recognise the person from speed, certain key strokes, the order they do things, etc, (it could even remember these people).
Then it needs to make an intelligent decision on there level of ability and casually advise them of their level and act appropriately, suggestions include.....
shutting down windows with no warning whatsoever,
increasing font sizes and enlarging pixels on pictures,
display a 'stupid' diagram,
a small monkey appearing on the screen,
advising them of the decision made,
printing their whole c drive in some kind of list,
pointing and laughing,
if they have used it before and been caught out - advise them of this then do the above.
If you could have it on my desk by monday that would be great
Thanks
|
|
|
|
|
Uhhhh...whatever...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Can anyone suggest the right approach for the below mentioned issue/combination:
we have 3tier architecture application in vb and we r migrating it to vb.net in horizontal approach
first we r converting at server side(com+) vb dlls to vb.net we done it well
1). using .NET dll as part of server (MTS, COM+)
2). VB as front end
3). VB client (interfaces) is on one machine and server is on the other machine.
4). Using UDT (User Defined Type) for passing the info to SERVER from CLIENT and visa versa.
but our problem :
In the above mentioned combination, connecting from Client to the Server machine, in the client side we need to have LIBRARY, which creates UDTs (User Defined Type) and passing the info to the server DLL as argument. Here can the UDT be built on VB or .NET framework (as we understood that both can be allowed) ?, but we want the best approach for MARSHALLBYVAL. Please suggest us.
|
|
|
|
|
I have a simple VB6 function that loads a nominated DLL in another process using the CreateRemoteThread method - this is described elsewhere, and involves using CRT to trigger a LoadLibrary call in the target process.
I've never had it fail (assuming the loaded dll is well-behaved, of course), but now I have found that there is one type of DLL for which it fails!
It refuses to work with my customised VB6 dll's, by which I mean DLL's produced by changing the VB6 compile-time LINK command options to substitute my VB DLLMAIN procedure, and including a DEF file to export my VB functions.
When I try to inject one of these dll's, I simply get an exit code of zero, indicating the LoadLibrary call failed, I assume, but without the GetLastError code from the target process of course I have no idea why it failed.
I will try further tests to see if I can retrieve that error code in the target program.
Meanwhile, I'd be grateful for any suggestions....
I can provide a trivial 1-function DLL produced this way, if anybody thinks the problem might be spottable by loading it and having a peek. It simply refuses to be injected (with CRT, anyway).
Thanks
Dr Memory
MathImagics Software Engineering
Cutmill, Surrey, UK
Algorithms`R`Us
|
|
|
|
|
In trying alternative ways to achieve my objective, I discovered this problem is not specific to my customised DLL's.
I inject a non-VB dll, which in its DLLMAIN tries to create an object provided by a conventional ActiveX DLL.
This is a common and easy thing to do, I built an import/export table modifier using it...
But it just won't work if the dll is injected with CreateRemoteThread! The attempt to create the object instance fails.
Load the dll yourself though, and it works like a charm!
|
|
|
|
|
i want to search for 2 words or more but i must be able to search the words in the same sentance, same paragraph and same page.. in a word doc file..
i'm now usind the indexing service and connect to sqlServer..
i can search words between up 8 words by using "NEAR()" any one can help in search on a sentance and on a paragrah???
|
|
|
|
|
Something like this..........
Dim oExcel as object
Dim oWorkbook as object
Dim oWorkSheet as object
Dim strFilename as string
Set oExcel = CreateObject("Excel.Application")
Set oWorkbook = oExcel.Workbooks.Open(PathtoASpreadSheet)
strFilename = "Filename" & Date & "Filename" & ".xls"
oExcel.DisplayAlerts = True
oWorkbook.SaveAs strFilename
Set oWorkSheet = oWorkbook.worksheets("Sheet1")
You can then access the cells in the worksheet directly using various methods
like.........
'hide a column
oWorkSheet.Columns("P").Hidden = True
'Set a value of a cell
oWorkSheet.Cells(1, "A") = "Hello World"
'change interior colour
oWorkSheet.Range(oWorkSheet.Cells(1, "A"), oWorkSheet.Cells(1, "H")).Interior.Color = &H80FFFF
'save and close
oWorkbook.Save
oWorkbook.Close
oExcel.Quit
'terminate excel
Set oworkbook = nothing
Set oworksheet = nothing
Set oExcel = nothing
Bear in mind that to access excel constants they will need to be declared
like........
Const xlNumberAsText = 3
Const xlContinuous = 1
Const xlCellValue = 1
Const xlEqual = 3
Const xlBetween = 1
Const xlNotBetween = 2
Const xlValidateDate = 4
Const xlValidAlertStop = 1
Const xlGreater = 5
Const xlValidateList = 3
Example of use
oWorkSheet.Range(oWorkSheet.Cells(1, "A"), oWorkSheet.Cells(1, "H")).Borders.LineStyle = xlContinuous
Hope that helps
Purple Monk
"I am what i am, and i do what i do, but sometimes i do, what you want me to do, but only after much wining."
|
|
|
|
|
How can I open/modify/write/close an .xls spread-sheet from VB6? I tried DAO and ADO but didn´t seem to work (most often error was 'ISAM object not insertable', or some insanity of the like) Thanks in advance.
Pablo.Ar
|
|
|
|
|
Hi,
Yeah... It is simple to delete an existing file... But what I need an implementation for the following algorithm. I will explain with a small example. I have an .exe file and execute it manually and I have a program which deletes a file. I run the program to delete the file which is currently executing. What I want is loop the following bit until the file is released i.e., until the program has ended.
Does anyone know this how to do it.
Thanks in Advance. The following is a general algorithm.
For WaitTime As Int16 = 0 To 220<br />
System.Threading.Thread.Sleep(1000)<br />
' Delete temporary file as soon as possible after it is freed.<br />
Try<br />
If DeleteFile(ToFile)=True Then<br />
'File Deleted<br />
Exit For<br />
End If<br />
Catch ex As Exception<br />
<br />
End Try<br />
Next ' Otherwise, loop again and keep waiting...
Prabhu Ram Prasath
prabhuram@dsrc.co.in
|
|
|
|
|
if i understand your question you can try to put this code in a Sub (Function) and than if DeleteFile(ToFile) returns False you can just recursively call the Sub (function) again. it could be something like this:
Public Sub Del_File(ToFile)<br />
For WaitTime As Int16 = 0 To 220<br />
System.Threading.Thread.Sleep(1000)<br />
' Delete temporary file as soon as possible after it is freed.<br />
Try<br />
If DeleteFile(ToFile)=True Then<br />
'File Deleted<br />
Exit For<br />
Else<br />
Del_File(ToFile)<br />
End If<br />
Catch ex As Exception<br />
'<br />
End Try<br />
Next<br />
End Sub
you can also declare WaitTime variable as Static (in VB .Net) so you do not start counting from the beginning every time
sony speed
|
|
|
|
|