ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 03-17-2011
Ilivid zheng Ilivid zheng is offline
Flexsim User
 
Join Date: Dec 2010
Posts: 19
Downloads: 361
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 115
Ilivid zheng is on a distinguished road
Question Problem with connection of Microsoft SQL server2005

Hello,
I want to use Microsoft SQL server2005 as a database,but i have no idea of steps to connect it. anyone could tell me ?

thanks a lot .

Ilivid
  #2  
Old 03-17-2011
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Set up an ODBC Data Source Name (DSN) that points to your SQL database and then give that name in the dbopen() command in Flexsim. That's done in odbcad32.exe which is usually listed under 'Administrative Tools' in the control panel as "Data Sources (ODBC)", or try just entering odbcad32.exe in the search box under Start.

That's the connection, but if you don't know about that there's probably other stuff you need to know too. Post back here and we'll try and cover each point in turn. In particular take a look at the command documentation for the following ODBC commands - dbopen(), dbclose(), dbsqlquery(), dbchangetable(), dbgetmetrics(), dbgetfieldname(), dbgetnumrows(), dbgetnumcols(), dbgettablecell(), dbsettablecell()
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Ilivid zheng (03-20-2011)
  #3  
Old 03-20-2011
Ilivid zheng Ilivid zheng is offline
Flexsim User
 
Join Date: Dec 2010
Posts: 19
Downloads: 361
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 115
Ilivid zheng is on a distinguished road
Post

I try it.There is a popup windonw as flowing when i run model.

---------------------------
ODBC Error
---------------------------

Scheduling

SQL server does not exist or Access denied
Driver: [Microsoft][ODBC SQL Server Driver][Shared Memory]
ODBC Code:08001
Flexsim Code: 2 - SQLConnect
---------------------------
OK
---------------------------

I write the code in the OnRest trigger as following.

dbopen("Scheduling","select * from table_1",1,0);

The "Scheduling" is DSN. And set the driver as SQL server as shown by attachament. I just want to try if it can connect to SQL. but failed!

Any ideas on how to avoid this error occuring?

Thanks in advance!
Attached Thumbnails
Click image for larger version
Name:	Driver selecting.png
Views:	129
Size:	7.9 KB
ID:	1305  
  #4  
Old 03-21-2011
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Are you using a 64-bit OS? If so you might want to try the database admin tool found at C:/Windows/SysWoW64/odbcad32.exe rather than using the one in the control panel.

Can you try and connect using ODBC from another application (Excel) too? If that works then we can dig further.
  #5  
Old 03-23-2011
Ilivid zheng Ilivid zheng is offline
Flexsim User
 
Join Date: Dec 2010
Posts: 19
Downloads: 361
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 115
Ilivid zheng is on a distinguished road
Default

Hi Jason
I am using a 32-bit OS. And i try connect Flexsim with other application(Excel,Access),it works well.
  #6  
Old 03-23-2011
AJ Bobo's Avatar
AJ Bobo AJ Bobo is offline
Flexsim Senior Developer
 
Join Date: Jul 2007
Posts: 108
Downloads: 8
Uploads: 0
Thanks: 23
Thanked 89 Times in 41 Posts
Rep Power: 221
AJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the rough
Default

I did a little testing and was able to get the 08001 error if the SQLServer service wasn't running. If that's the case, then Flexsim cannot connect to it. Use the SQL Server Connection Manager to make sure that the server is actually running correctly.

Also, I noticed that your dbopen() call uses a SQL statement as the initial command, but you pass a 1 as the third parameter. This will tell Flexsim to work in Table mode, instead of SQL mode. If you want to use SQL queries to interact with the database, then you need to pass a 0 as the third parameter. The command should be:
dbopen("MyDatabase","SELECT * from MyTable",0,0);
The Following User Says Thank You to AJ Bobo For This Useful Post:
Ilivid zheng (03-29-2011)
  #7  
Old 03-29-2011
Ilivid zheng Ilivid zheng is offline
Flexsim User
 
Join Date: Dec 2010
Posts: 19
Downloads: 361
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 115
Ilivid zheng is on a distinguished road
Default

Thanks for your message!
several days I did not online.first i check the sever,it is runnning correctly.and then i try it again. i set a userDSN as "MyDatabase".when i test Database Source,there is Connection failure indication.i thought this is why i cannot connetct to SQL in flexsim.
  #8  
Old 03-30-2011
AJ Bobo's Avatar
AJ Bobo AJ Bobo is offline
Flexsim Senior Developer
 
Join Date: Jul 2007
Posts: 108
Downloads: 8
Uploads: 0
Thanks: 23
Thanked 89 Times in 41 Posts
Rep Power: 221
AJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the rough
Default

It sounds like the problem is at the DSN level. Once you have configured the DSN so that it connects to the database correctly, Flexsim should be able to connect to the database as well.
The Following User Says Thank You to AJ Bobo For This Useful Post:
Ilivid zheng (04-04-2011)


Thread Thread Starter Forum Replies Last Post
When I want to delete the connection of 'D' key generattion. syseo Container Terminal (CT) Library 1 01-19-2011 08:05 AM
PostgreSQL ODBC connection kartikjadhav Q&A 4 12-21-2010 07:23 AM
PLC connection, positioning issues Stephan Seidel Q&A 13 04-08-2010 01:02 AM
Batch connection changes KelvinHo Q&A 2 02-05-2010 03:01 PM
Port Connection Problem Joe Allen Q&A 2 05-11-2009 10:56 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.