Can someone tell me why I am getting an error for the the following sql statement when I execute it against a MySQL Database. This sql statement works great with MSSQL and Access:
VB Code:
Dim strFieldName as String Dim strTableName as String strFieldName = "MyFieldName" strTableName = "MyTableName" strSQL = "SELECT " & strFieldName & " as FieldName " '<==Aliasing MyFieldName as fieldname strSQL = strSQL & "FROM " & strTableName & " "
then I attempt to Add a new record into the table:
VB Code:
rs.AddNew strValue = Me.Text1.Text rs!FieldName = strValue & "" rs.Update '<====This is the line I get the error on
I get the following error message: Error -214721900 (Unknown column 'fieldname' in 'field list)
Am I to assume that MySQL doesn't allow you to allias fieldnames?
If I change the fieldname to the following:
VB Code:
Dim strFieldName as String Dim strTableName as String strFieldName = "MyFieldName" strTableName = "MyTableName" strSQL = "SELECT " & strFieldName & " " 'as FieldName " <==Aliasing MyFieldName as fieldname strSQL = strSQL & "FROM " & strTableName & " "
VB Code:
rs.Fields(0).Value = strValue & ""
it works fine, any ideas??
P.S. I am using mysql-4.1.12-win32 version





Reply With Quote