thatoneguy
07-23-2006, 01:50 AM
How to use MySQL with 3D Studio Max
1. Download and install/configure a MySQL server. (I like PHPDev since it has such an excellent intaller) http://www.firepages.com.au/
2. Download and Install the ODBC Driver: http://dev.mysql.com/downloads/connector/odbc/3.51.html
[Steps 3-8 from:] http://dev.mysql.com/doc/refman/5.0/en/myodbc-configuration-dsn-windows.html]
3. Go to your Administrative Tools in windows. (Start -> Control Panel -> Administrative Tools in XP)
4. Click Data Sources (ODBC)
5. Click the "System DSN" Tab.
6.Click Add
7. Select MySQL
8. Data Source Name: Name of Connection
Description: Description of Connection
Server: Server address
User: Username
Password: 12345... wait I mean the password that you use.
Database: which database you want connected
9. Load 3D Studio Max 8.
10. Open your Listener Window
11. Examples:
Getting Data From a MySQL Database (Database: "test" Table: "TestTable")
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "SELECT * from TestTable" TestConn <-- Standard SQL Request in ""
var = recordset.GetRows ()
-- if you want to select a field of data use: Var.DataArray[i]
Sending Data to a MySQL Database (Database: "test" Table: "TestTable", a table with two fields "id" (autoincremented) and "name" (string)
TestConn=createOLEObject "ADODB.Connection"
[i]TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "SELECT * from TestTable" TestConn 1 3 <-- last 2 numbers are the ADO cursortype and locktype respectively. For more information read the ADO documentation provided below. All you really need to know, is they allow data to be sent back to the database.
recordSet.AddNew #("id", "name") #(undefined,"jimmike")
Editing Data in a MySQL Database (Database: "test" Table: "TestTable", a table with two fields "id" (autoincremented) and "name" (string)
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "SELECT * from TestTable WHERE id = 1" TestConn 1 3
recordSet.update #("id", "name") #(1,"newname")
Deleting Data From a MySQL Database (Database: "test" Table: "TestTable", a table with two fields "id" (autoincremented) and "name" (string) where there is a field of [5,$string]
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "SELECT * from TestTable" TestConn 1 3
recordSet.delete
Creating a New Table in a MySQL Database (Database: "test")
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "CREATE TABLE `NewTable` (`field01` INT( 4 ) NOT NULL ,`field02` VARCHAR( 128 ) NOT NULL )" TestConn 1 3
//creates a new table with two fields: Field 01 and Field 02. Field 01 is an integer of length 4 and Field 2 is a string with a length of 128. For more information refer to SQL Documentation or just use phpmyadmin and use their fancy dancy interface. :)
Deleting a Table in a MySQL Database (Database: "test")
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "DROP TABLE `newtable`" TestConn 1 3
----------------------------------
I'll try to keep updating this as I learn more.
I found a comprehensive set of documentation on the ADO instruction set:
http://docs.sun.com/source/817-2514-10/Ch11_ADO3.html (http://docs.sun.com/source/817-2514-10/Ch11_ADO3.html)
For more examples see the 3D Studio Maxscript reference related to SafeArrayWrapper.
- Gavin Greenwalt
1. Download and install/configure a MySQL server. (I like PHPDev since it has such an excellent intaller) http://www.firepages.com.au/
2. Download and Install the ODBC Driver: http://dev.mysql.com/downloads/connector/odbc/3.51.html
[Steps 3-8 from:] http://dev.mysql.com/doc/refman/5.0/en/myodbc-configuration-dsn-windows.html]
3. Go to your Administrative Tools in windows. (Start -> Control Panel -> Administrative Tools in XP)
4. Click Data Sources (ODBC)
5. Click the "System DSN" Tab.
6.Click Add
7. Select MySQL
8. Data Source Name: Name of Connection
Description: Description of Connection
Server: Server address
User: Username
Password: 12345... wait I mean the password that you use.
Database: which database you want connected
9. Load 3D Studio Max 8.
10. Open your Listener Window
11. Examples:
Getting Data From a MySQL Database (Database: "test" Table: "TestTable")
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "SELECT * from TestTable" TestConn <-- Standard SQL Request in ""
var = recordset.GetRows ()
-- if you want to select a field of data use: Var.DataArray[i]
Sending Data to a MySQL Database (Database: "test" Table: "TestTable", a table with two fields "id" (autoincremented) and "name" (string)
TestConn=createOLEObject "ADODB.Connection"
[i]TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "SELECT * from TestTable" TestConn 1 3 <-- last 2 numbers are the ADO cursortype and locktype respectively. For more information read the ADO documentation provided below. All you really need to know, is they allow data to be sent back to the database.
recordSet.AddNew #("id", "name") #(undefined,"jimmike")
Editing Data in a MySQL Database (Database: "test" Table: "TestTable", a table with two fields "id" (autoincremented) and "name" (string)
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "SELECT * from TestTable WHERE id = 1" TestConn 1 3
recordSet.update #("id", "name") #(1,"newname")
Deleting Data From a MySQL Database (Database: "test" Table: "TestTable", a table with two fields "id" (autoincremented) and "name" (string) where there is a field of [5,$string]
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "SELECT * from TestTable" TestConn 1 3
recordSet.delete
Creating a New Table in a MySQL Database (Database: "test")
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "CREATE TABLE `NewTable` (`field01` INT( 4 ) NOT NULL ,`field02` VARCHAR( 128 ) NOT NULL )" TestConn 1 3
//creates a new table with two fields: Field 01 and Field 02. Field 01 is an integer of length 4 and Field 2 is a string with a length of 128. For more information refer to SQL Documentation or just use phpmyadmin and use their fancy dancy interface. :)
Deleting a Table in a MySQL Database (Database: "test")
TestConn=createOLEObject "ADODB.Connection"
TestConn.Open "driver={MySQL ODBC 3.51 Driver}; server=localhost; database=test"
recordSet = createOLEObject "ADODB.Recordset"
recordSet.Open "DROP TABLE `newtable`" TestConn 1 3
----------------------------------
I'll try to keep updating this as I learn more.
I found a comprehensive set of documentation on the ADO instruction set:
http://docs.sun.com/source/817-2514-10/Ch11_ADO3.html (http://docs.sun.com/source/817-2514-10/Ch11_ADO3.html)
For more examples see the 3D Studio Maxscript reference related to SafeArrayWrapper.
- Gavin Greenwalt
