|
What is 'dbConn'?
I'm confused how selectAll is a method of dbConn...
Steve
|
|
|
|
|
dbConnection is a class I created with all functions in that deal with the database.
In the forms I want to connect to the database I put this line of code:-
Dim dbConn As dbConnection = New dbConnection()
selectAll is a function I created to select all from the given table name, put the contents into a dataSet and display in a DataGrid.
|
|
|
|
|
What is the definition of this 'selectAll' method?
Steve
|
|
|
|
|
This is the selectAll code, I just called it selectAll(select *) as that is what I am doing from the database, selecting all from a table and displaying it to the user.
Public Function selectAll(ByVal strSQL As String, ByVal tableName As String)<br />
Dim dset As DataSet = New DataSet()<br />
sqlite_cmd.CommandText = (strSQL)<br />
sqlite_datareader = sqlite_cmd.ExecuteReader()<br />
<br />
Dim sqlite_dataAdapter As SQLiteDataAdapter = New SQLiteDataAdapter(strSQL, sqlite_conn)<br />
sqlite_commandBuilder = New SQLiteCommandBuilder(sqlite_dataAdapter)<br />
sqlite_dataAdapter.Fill(dset, tableName)<br />
Return dset<br />
End Function
|
|
|
|
|
Are those sqlite_*** items custom components or your own classes?
There is no expected line:
Dim sqlite_commandBuilder As SQLiteCommandBuilder
What are the 'CommandText' and 'ExecuteReader' lines doing?
Nothing as far as I can see...
Steve
|
|
|
|
|
Hi Steve, the sqlite_*** are my names I've given to them. Like in the code above, I've simply added the _ so when I come to use it elsewhere I know what it is, so SQLiteCommandBuilder becomes sqilte_commandBuilder. It's just easier for me. They come from a 3rd party wrapper which is finisar.sqlite which can be found at http://adodotnetsqlite.sourceforge.net/
the expected line of "Dim sqlite_commandBuilder As SQLiteCommandBuilder" is present and has been declared at the top of the dbConnection class with all the other things that need declaring.
Now that you mention it I don't know what those two lines are doing, they are there from when I started this project a long time ago and as it was working I never took anything out.
I've took them out and they makeno difference to the error messge so it looks as if they were not needed at all.
-- modified at 12:47 Saturday 5th August, 2006
|
|
|
|
|
Well, I'm at a loss my friend!
The only other thing I can see is the line:
Dim dset As DataSet
is repeated in 'cmbInsertData_SelectedIndexChanged' and in your 'selectAll' function. Don't know if that would cause an error...
I suspect it has something to do with one of your third party components. Maybe one of them is corrupted or something.
Good luck!
Steve
|
|
|
|
|
It's very weird as you would suspect it to either work on both my home and Uni PC's or neither, not to work on one and not the other.
Anyway thanks for your help and suggestions, they were very much appreciated.
Thanks again
John
|
|
|
|
|
Yes. This really suggests it is something other than your code.
Steve
|
|
|
|
|
I think I should be just glad it works at University and leave it at that.
Thanks again for your time and help, much appreciated.
John
|
|
|
|
|
newbjohny wrote: I have been taught this way at University so as not to crash out the program.
Your try/catch blocks here are being used for debugging purposes not to prevent the application from crashing. Using try/catch for debugging is a waste of time when there are better tools available.
Did your university not teach you how to set breakpoints and step through code and how to watch variables?
You need to find out the full stack trace of where the exception was thrown. By catching the exception and displaying only the message you've thrown all that information away - get rid of the try/catch and see where the application actaully crashes. When it does the Visual Studio debugger will show you exactly where the crash is (even if it is in code you did not write)
If you are missing a referrence your application is unlikely to compile on your home machine.
|
|
|
|
|
Hi, sadly they did not teach us to do anything other that the try and catch, to be honest they never really taught us, all the lecture notes were ripped straight from the recommended text book. Anyway thats a aside issue.
I've taken out the try-catch and it still crashes out with the same error, but two lines of code are highlighted, the one mentioned earlier in the form :-
dset = dbConn.selectAll("SELECT * FROM " & tblName, tblName)
and one in selectAll function in the connection class:-
sqlite_dataAdapter.Fill(dset, tableName)
A third line is highlighted in dissassembly but I have no idea what this is :-
00000014 mov ecx,eax
|
|
|
|
|
Ignore the disassembly - what is in the call stack? It should be in the lower half of the Visual Studio window. (Use the following to show it if it is not displayed: Debug-->Windows-->Call Stack)
newbjohny wrote: dset = dbConn.selectAll("SELECT * FROM " & tblName, tblName)
What is dbConn? I would assume it is a connection, but selectAll is (1) Not a standard method on a connection class and (2) does not conform to the .NET naming guidelines so it may have been written by someone with a Java background.
|
|
|
|
|
The previous two messages I wrote were from the Call stack.
dbConnection is a class I created with all functions in that deal with the database.
In the forms I want to connect to the database I put this line of code:-
Dim dbConn As dbConnection = New dbConnection()
selectAll is a function I created to select all from the given table name, put the contents into a dataSet and display in a DataGrid.
|
|
|
|
|
newbjohny wrote: Private Sub cmbInsertData_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbInsertData.SelectedIndexChanged
newbjohny wrote: Public Function selectAll(ByVal strSQL As String, ByVal tableName As String)
Are these two methods on the same class?
-- modified at 12:04 Saturday 5th August, 2006
What are the fields (aka member variables) on the class(es)?
|
|
|
|
|
No, the function is in a dbConnection class and the cmbinsertdata is on a form.
I'm sorry but I do not know what a member variable is.
Is there someway I could zip my code and email it to you, it may be easier if you could see the code.
John
|
|
|
|
|
newbjohny wrote: I'm sorry but I do not know what a member variable is.
Do they teach you anything at this university?
member variable, also known as a class field, for example:
public class SomeClass
{
private int someMemberVariable;
}
It is a variable that exists within the scope of an instance of a class. All methods and properties in the class can access the variable.
You might want to invest in a couple of books that the university did not recommend.
|
|
|
|
|
Ive just never heard them be called this before,
in the dbConnection class there is :-
Public tableNames() As String
Public indexNames() As String
Public triggerNames() As String
Public viewNames() As String
Public columnNames As New ArrayList()
Public columnTypes As New ArrayList()
Dim tables, i As Integer
Dim sqlite_conn As SQLiteConnection
Dim sqlite_cmd As SQLiteCommand
Dim sqlite_datareader As SQLiteDataReader
Dim sqlite_dataAdapter As SQLiteDataAdapter
Dim dset As DataSet = New DataSet()
Dim sqlite_commandBuilder As SQLiteCommandBuilder
Private data_Table As New DataTable()
Private rowPos As Integer = 0
in the viewdata form there is :-
Dim dbConn As dbConnection = New dbConnection()
Dim tableName As String
Dim tblName As String
|
|
|
|
|
What is this?
tblName = (cmbInsertData.Text)
setTableName(tblName)
I do not see a declaration of the Variable tblName ( Dim tblName as String ). I believe VB will create this as an Object type without the Dim statment, and then you are trying to us it as a string?
what is setTableName? are you expecting the variable tblName to change when it comes out of setTableName?
Step thru the code line for line in debug and you can see exactly what all your variables are and what might be missing.
Joe
-- modified at 0:37 Sunday 6th August, 2006
|
|
|
|
|
Hi Joe, I have declared tblName as a String at the top of the form as it is used a few times throughout the form. setTableName(tblName) is a method within a Module I created to store the name of the table in the database I am using so that I can use it in another form with the method getTableName.
I've looked through and can't find any errors, like I said before it works fine at University. I emailed someone my project from another forum and they said it worked fine on their pc also so were unsure as the problem, theyve uploaded it to the forum if anyone wants to download it and look at the code first hand they can.
It is message 12 by user "doWhileSomething" and the program is in the link Program, the forum is at :-
http://www.vbcity.com/forums/topic.asp?tid=131204&page=2RID424741
|
|
|
|
|
Hi, I have now fixed this problem, my MDACs were not up to date, so once I updated these everything worked fine.
Thanks again.
John.
|
|
|
|
|
Hello, This is partly an MS-Word question but I am using VB subroutines which is where my problem arises.
I have created a find and replace script that uses wildcards to find a pattern throughout a Microsoft Word 2003 document and replace the pattern with itself but with a different font color. The find and replace portions both work great as I am recording the macro (finding all instances of the pattern and changing the color). However, when I go back and run the macro to test it, it only finds the first instance of my pattern. Word apparently does not have the ability to record finds for all instances of a pattern in one pass.
I tried putting a EOF or LOF function to force the macro to run until the end of file is reached but I get caught in an endless loop and I have to shut down the application all together. Does anyone know of a way of performing this action. Below is my code without a loop where only the first instance of the pattern is found.
Thanks
Sub test()
'
' test Macro
' Macro recorded 8/5/2006 by Harold Woodall
'
Selection.Find.ClearFormatting
For Counter = 1 To 500
With Selection.Find
.Text = "(\>[A-Z,a-z]{1,250}\<)"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
With Selection.Font
.Name = "Times New Roman"
.Size = 12
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorBlue
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
Next
End Sub
|
|
|
|
|
That is,a windows form consist of 3 textboxes say name,age,address.One can enter values in these textboxes a it is added into a datagrid placed below.
What i want to know is in this grid a row is selected ,if the focus is now on the datagrid & if i am pressing enter key means i want tht values to be set in the corresponding textboxes.What i want to know is how can we work key-press events within the datagrid
with regards
rahul
let the noble thought come from every side:Rig Veda
|
|
|
|
|
you could use a really dirty trick.
Create a button and set it as the default button of the form, so that it will fire a Button.Click Event as you press the enter key. in the method handling that event, put the code that writes the values selected in the textboxes. then hide the button.
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
Hi,
This is more of a general question with VB.NET than asking for code. If you're making a TCP/IP server that you expect to get many connections (30 and up) do you create a new thread per tcpClient or Socket or one thread for X amount of connections... or something different? And would your answer be different if the number of connections were 2,000 and above?
|
|
|
|