Error with OleDb when using text field in table.

malitice

Active member
Joined
Feb 20, 2005
Messages
41
Programming Experience
1-3
I wrote a program that works just fine normally, but when I change one of the fields in the mysql database to a text field (or mediumtext, long text blob etc) the program throws an error:

VB.NET:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

Additional information: No error information available: DB_E_NOTABLE(0x80040E37).
And flags the bold line:

EDIT: for some reason the forums are adding spaces to the line by the 'n', those are not in the code.
VB.NET:
	 Dim fdCon As New OleDb.OleDbConnection("Provider=MySQLProv;Data Source=test;User Id=root;Password=;")
		Dim fdCom As New OleDb.OleDbCommand("SELECT * FROM lib1 WHERE id = '" & TextBox1.Text & "'", fdCon)
		fdCom.Connection.Open()
[b]	   Dim fdRead As OleDb.OleDbDataReader = fdCom.ExecuteReader(CommandBehavior.CloseConnection)[/b]
		While fdRead.Read
		do somthing
		end while
It normally works but as soons as the field type is changed (to larger than tinytext) it errors. Is there a byte or size limit when using OleDb?
 

malitice

Active member
Joined
Feb 20, 2005
Messages
41
Programming Experience
1-3
I retried it a few different ways, and it gives me the same error with the following as my table:

VB.NET:
CREATE TABLE `test` (
  `test` text NOT NULL
) TYPE=MyISAM;
and the following as my connection
VB.NET:
	   Dim fdCon As New OleDb.OleDbConnection("Provider=MySQLProv;Data Source=test;User Id=root;Password=;")
		Dim fdCom As New OleDb.OleDbCommand("SELECT * FROM test", fdCon)
		fdCom.Connection.Open()
		Dim fdRead As OleDb.OleDbDataReader = fdCom.ExecuteReader(CommandBehavior.CloseConnection)
		While fdRead.Read
			textbox1.Text = fdRead.GetValue(0)
		End While
		fdCom.Connection.Close()
So my question is is there a way to be able to read a text field in a mysql table?
 

malitice

Active member
Joined
Feb 20, 2005
Messages
41
Programming Experience
1-3
Well after some testing and reading the myoledb manual I figured it out.

For reference for anybody else that needs it

VB.NET:
 Dim fdCom As New OleDb.OleDbCommand("SELECT substring(Table,1,XXXXX) FROM test", fdCon)
Table is the name of the field, the xxxxxx are the number of characters you want to show.
 
Top Bottom