|
Hi
Im trying to work with and save large amount of binary data (bytes) but I cannot figure out how to do this in visual basic 6.
In C you can setup a large buffer of bytes, "char buffer[123123]", work in this buffer and then save a part of it with a "fwrite(buffer + 321, 1, 4321)".
In visual basic I can setup a byte array "Dim buffer(1073741824) As Byte" but I cannot get this array as large as I want, about 10Mbytes.
And how can I save only a small part of a byte array fo a file? If I do it Like:
Open "c:\test.raw" For Binary As #FileNumber
Put FreeFile, , bindata
Close FreeFile
Then the whole byte array will be written to the file. I have seen solutions for small amount of bin data where a collection is used and each byte element in the collection is saved in a while next lop with a put in it, but that cannot be that efficient or?
regards Me
|
|
|
|
|
can i get the names of enum items at runtime using VB6?
i.e. does vb6 support some kind of metainformation
(at least a little)?
|
|
|
|
|
No, you can't. VB6 doesn't support Reflection.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes it does. Try reading up on the typelib utility and also there is an example on how to make your own typelib utility from the cd. Using that, you can grab the classes, types, or enums defined in a dll or exe.
|
|
|
|
|
Great! Didn't know that.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am using an OLEDBDataAdapter to draw data out of an Access database. I am able to use the fill method and populate a flexgrid control with the data pulled. I need to be able to put this data in a text box though so that i can copy and paste all results in one shot. How do I Pupolate any control that I can pick more that one item with copy and paste action with multiple date. At current the command I am using is OLEDBDataAdapter.fill this is a very simple program. TIA
|
|
|
|
|
I was able to get the data into a listbox. Now I just need a little help in being able to copy selected items in the listbox and paste them into a seperate program. ie.. Copy to clipboard and paste in dos program. TIA
|
|
|
|
|
Hi Does anyone know how to script the deletion of a users mailbox in a Active Directory/Exchange 2000 environment?
Thanks
Andrew
www.purenetworking.net
|
|
|
|
|
Try to browe the script from here[^]There are a lot of script.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I need some help, or maybe just a reasonable suggestion to point me in the right direction.
I'm using a RichTextBox to display information in a single user app. I'm adding text to this RTB by way of a TextBox. My issue is this. I can't seem to find a simple way to cause the RTB to display the lastest text that was sent to it, since the text it at the bottom of the RTB. Once I send the new text I need the RTB to scroll to the bottom so the last text is visible. I have tried a API but I not having any luck.
Any suggestions?
Thanks for any help.
T
|
|
|
|
|
Yes it is try this
Public Sub DisText(ByVal text As String) <br />
txtmsgsrv.SelectionColor = ColorRes <br />
' <br />
txtmsgsrv.Focus() <br />
txtmsgsrv.AppendText(text) <br />
txtmsgsrv.Refresh() <br />
txtmsgsrv.Focus() <br />
txtmsgsnd.Focus() <br />
' <br />
txtmsgsrv.SelectionColor = Color.Black <br />
End Sub <br />
Hope this helps u,
Ravi.
|
|
|
|
|
It gets simpler:
RTB1.SelectionStart = RTB1.TextLength
RTB1.Focus()
RTB1.ScrollToCaret()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hmm... i cant remember whats the codings for navigating to the 1st record and the last record in the database?
any1 plz help
|
|
|
|
|
BindingManagerBase.Position Property
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsbindingmanagerbaseclasspositiontopic.asp
|
|
|
|
|
hmmm.. i dun quite understand how to add in my codings..
here my codings..
"
'this function is to show Tag number on a textbox
Public Sub loadHardwareTag()
Dim objDataReader As OleDbDataReader
Dim objCommand As OleDbCommand
Dim objCommand2 As OleDbCommand
Dim a As Integer
objCommand = New OleDbCommand
objCommand.Connection = conn
objCommand.CommandText = "select TagNo from Hardware"
objDataReader = objCommand.ExecuteReader
objDataReader.Read()
a = objDataReader("TagNo")
TxtTagNo.Text = a
objDataReader.Close()
"
however this only enable me to view the 1st record on the database. but what i want is to view the last record and +1 to show user what is the next record they gonna enter..
plz help?
|
|
|
|
|
Hi,
I have a table in my Access DB that looks like this:
ID (autonumber)
MyNum1 (number)
MyNum2 (number)
MyStr1 (string)
MyTime (Date/Time)
I've used the Designer to create a typed dataset and a Data Adapter for that table. I added a row to that table and updated the db:
mytable.AddMyDataRow(myrow)
Update( New DataRow() { myrow } )
Because I only want to update that one single row.
I closed my app and re-opened it, and I immediately fill the dataset with the rows from the table, including the one above.
Now, I want to add another row. I do exacly the same thing, and I get an exception when calling Update on the new row:
"Parameter ?_2 has no default value."
The ?_2 changed to ?_1 after I deleted the adapter and re-created it. Dunno why.
I'm really stuck on this. Anyone has an idea what's going on?
Thanks.
/=/=/=/= Sagmam =\=\=\=\
|
|
|
|
|
Without seeing the code that your having a problem with, it's going to be impossible to tell you what wrong. We'd have to see both the code you've written and the code from the "Windows Forms Designer Generated Code" region. Doing everything with the designer makes it difficult to determine what's wrong because your actions don't map to code we can fix directly. It's very often better to write all the database code yourself because you have must greater control over problems like this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You're right, of course.
But I'd like to correct myself. I've solved the problem of the ?_X exception (I was trying to update a row of the wrong type). However, I get a different execption:
Concurrency violation: the UpdateCommand affected 0 records.
The problematic table, TaskHistory, is the a table that holds history of a task, so it's a child table of the Tasks table. I've added the proper relationship in the dataset. This is the table definition, as it appears in MS Access Designer:
ID (autonumber)
TaskID (foreign key to the Tasks table)
PersonID (number)
Description (string)
CreationTime (date/time)
This is the code that was generated for the problematic adapter:
'dbaTaskHistory
'
Me.dbaTaskHistory.DeleteCommand = Me.OleDbDeleteCommand4
Me.dbaTaskHistory.InsertCommand = Me.OleDbInsertCommand4
Me.dbaTaskHistory.SelectCommand = Me.OleDbSelectCommand10
Me.dbaTaskHistory.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "TaskHistory", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("CreationTime", "CreationTime"), New System.Data.Common.DataColumnMapping("Description", "Description"), New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("PersonID", "PersonID"), New System.Data.Common.DataColumnMapping("TaskID", "TaskID")})})
Me.dbaTaskHistory.UpdateCommand = Me.OleDbUpdateCommand4
'
'OleDbSelectCommand10
'
Me.OleDbSelectCommand10.CommandText = "SELECT CreationTime, Description, ID, PersonID, TaskID FROM TaskHistory WHERE (Ta" & _
"skID = ?) ORDER BY CreationTime DESC"
Me.OleDbSelectCommand10.Connection = Me.dbcTeamTracker
Me.OleDbSelectCommand10.Parameters.Add(New System.Data.OleDb.OleDbParameter("TaskID", System.Data.OleDb.OleDbType.Integer, 0, "TaskID"))
'
'OleDbInsertCommand4
'
Me.OleDbInsertCommand4.CommandText = "INSERT INTO TaskHistory(CreationTime, Description, PersonID, TaskID) VALUES (?, ?" & _
", ?, ?)"
Me.OleDbInsertCommand4.Connection = Me.dbcTeamTracker
Me.OleDbInsertCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("CreationTime", System.Data.OleDb.OleDbType.DBDate, 0, "CreationTime"))
Me.OleDbInsertCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Description", System.Data.OleDb.OleDbType.VarWChar, 0, "Description"))
Me.OleDbInsertCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("PersonID", System.Data.OleDb.OleDbType.Integer, 0, "PersonID"))
Me.OleDbInsertCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("TaskID", System.Data.OleDb.OleDbType.Integer, 0, "TaskID"))
'
'OleDbUpdateCommand4
'
Me.OleDbUpdateCommand4.CommandText = "UPDATE TaskHistory SET CreationTime = ?, Description = ?, PersonID = ?, TaskID = " & _
"? WHERE (ID = ?) AND (CreationTime = ? OR ? IS NULL AND CreationTime IS NULL) AN" & _
"D (PersonID = ? OR ? IS NULL AND PersonID IS NULL) AND (TaskID = ? OR ? IS NULL " & _
"AND TaskID IS NULL)"
Me.OleDbUpdateCommand4.Connection = Me.dbcTeamTracker
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("CreationTime", System.Data.OleDb.OleDbType.DBDate, 0, "CreationTime"))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Description", System.Data.OleDb.OleDbType.VarWChar, 0, "Description"))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("PersonID", System.Data.OleDb.OleDbType.Integer, 0, "PersonID"))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("TaskID", System.Data.OleDb.OleDbType.Integer, 0, "TaskID"))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_CreationTime", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CreationTime", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_CreationTime1", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CreationTime", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_PersonID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PersonID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_PersonID1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PersonID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_TaskID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "TaskID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_TaskID1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "TaskID", System.Data.DataRowVersion.Original, Nothing))
'
'OleDbDeleteCommand4
'
Me.OleDbDeleteCommand4.CommandText = "DELETE FROM TaskHistory WHERE (ID = ?) AND (CreationTime = ? OR ? IS NULL AND Cre" & _
"ationTime IS NULL) AND (PersonID = ? OR ? IS NULL AND PersonID IS NULL) AND (Tas" & _
"kID = ? OR ? IS NULL AND TaskID IS NULL)"
Me.OleDbDeleteCommand4.Connection = Me.dbcTeamTracker
Me.OleDbDeleteCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_CreationTime", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CreationTime", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_CreationTime1", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CreationTime", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_PersonID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PersonID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_PersonID1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PersonID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_TaskID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "TaskID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand4.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_TaskID1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "TaskID", System.Data.DataRowVersion.Original, Nothing))
The following code sets the CreationTime field for all Added child rows to Now, and then tries to update the db. The Update command at the end throws the execption. Assume that there are currently 2 rows in the dataset: the first is Unchanged and the second is Added.
Dim AllRows = row.GetTaskHistoryRows
Dim rowHist As dsData.TaskHistoryRow
For Each rowHist In AllRows
If rowHist.RowState = DataRowState.Added Then
rowHist.CreationTime = Now.UtcNow
End If
Next
dbaTaskHistory.Update(AllRows)
where 'row' is the parent row from the Tasks table.
But since I got an exception, I tried to update each added record seperately like this:
Dim rowHist As dsData.TaskHistoryRow
For Each rowHist In row.GetTaskHistoryRows
If rowHist.RowState = DataRowState.Added Then
rowHist.CreationTime = Now.UtcNow
dbaTaskHistory.Update(New DataRow() {rowHist})
End If
Next
And it worked. However, it's not acceptible that I perform multiple updates for all history records - it's just too much and I don't see why I should. Unless, of course, it has something to do with the autonumber key, but I doubt it.
I hope this time I've provided enough info.
Thanks...
/=/=/=/= Sagmam =\=\=\=\
|
|
|
|
|
Another small update: I found out that it's actually the OTHER row (not the Added one) that caused the "0 records" exception! I tried to update it seperately, and I got the exception. Also, I believed it was Unchanged, but I was wrong - it was Modified. This leads me to the next question: what if the row was SUPPOSED to be modified? why would the update fail with "0 records" on such a row??? I do need the option to update existing records ...
thanks.
/=/=/=/= Sagmam =\=\=\=\
|
|
|
|
|
I was wondering if anybody knows why the following occurs:
If you write the following code the blnCheck = True
Dim blnCheck as Boolean<br />
blnCheck = "TEDDY" Like "*EDD*"
But if you use the variable strFind the blnCheck = False
textFind.text = "EDD"<br />
Dim blnCheck as Boolean<br />
Dim strFind as String = "*" & UCase(txtFind.text) & "*"<br />
blnCheck = "TEDDY" Like "strFind"
This is not the actual code I am having trouble with, but it demonstrates the problem in an abbreviated form.
Thanks
Andy S.
|
|
|
|
|
That's because Like is an operator and works on 2 String operands.
Result = <String> Like <String>
It's no different than if you used Result = 34 + 23 .
Dicescuz wrote:
Dim strFind as String = "*" & UCase(txtFind.text) & "*"
blnCheck = "TEDDY" Like "strFind"
This code will compare the String TEDDY to the String strFind and, of course, the result will be False.
I think your looking for
blnCheck = "TEDDY" Like strFind
Here, strFind evaluates to a String, *whatevertext* . In your previous statement, since you enclosed strFind in quotes, it evaluated to the String strFind , not the contents of strFind.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave you are the Man. Thanks to everyone on this site that has helped me. The Find Funtionality that I was working on now works. Great people, and great help!!!!!
|
|
|
|
|
The user saves an excel file to the system, then I grab that save directory path of that file. That much is done. I want to know how to open that excel file and send all the records (row by row or however) into a SQL Server table. I think I already have a connection established.
I don't want to use DTS, it should be done programmatically.
Thank you in advance for any help!
|
|
|
|
|
You're going to have to use the Excel Automation library to open Excel, load your sheet, and parse each line of your sheet and add it to the database yourself. You'll have to write the SQL statements, build the database command object and parameters, then assign the data from each cell to the appropriate parameter object, and finally execute it. You'll have to do this for each and every line of the Excel sheet you want to add to the database.
This[^] little article should get you started on Excel Automation. It does NOT cover any database code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That example would help me get from sql to populate an excel sheet, but I'm looking for the opposite order. I've got an excel file saved, now I can get the excel file to open. Now I just need to have maybe a loop go through taking each row from the xl file and shooting it into an existing sql table.
Thank you for your help.
|
|
|
|
|