kanber Posted June 20, 2009 Share Posted June 20, 2009 Hello, I created a logging which name is "ARIZALAR" with logging method ODBC. I add manuel a channel which name is "BAZAMANI". var.strbaslamasure = "11" Logging.ARIZALAR.AddValue("BASZAMANI", var.strbaslamasure) logging is ok. also I call data global dbase global qr global count global thetime global batch global start global strTime start=0 dbase = db.Open("cizgi") qr = db.Query(dbase,"select * from test445 where BASZAMANI = '11'") global counter counter = 0 while (!db.IsEOF(qr)) start[counter] = db.Field(qr,"BASZAMANI") counter++ db.MoveNext(qr) endwhile db.CloseQuery(qr) db.Close(dbase) and calling the data is ok also. But I am using OPC in my programs. I add a chanel from opc device which name is "Device1MWBaslamaDakika_In" and I used function logging.ARIZALAR.AddChannel("Device1MWBaslamaDakika_In",6) and channel added to ARIZALAR. then I open datas with excel and I see field name "DEVICE1MWB" then I go to calling data sequence. global dbase global qr global count global thetime global batch global start global strTime start=0 dbase = db.Open("cizgi") qr = db.Query(dbase,"select * from test445 where DEVICE1MWB= '5'") global counter counter = 0 while (!db.IsEOF(qr)) start[counter] = db.Field(qr,"BASZAMANI") counter++ db.MoveNext(qr) endwhile db.CloseQuery(qr) db.Close(dbase) Dqafactory gives error message "O1004 Unable to run query: bbb Line 11 - Uncaught error in sequence bbb" also noticed that I want to add a lot of channel like device1mw....... I want to read all channel for logging on startup from text file. then I will add to logging from file. Thanks, Link to comment Share on other sites More sharing options...
AzeoTech Posted June 20, 2009 Share Posted June 20, 2009 For any sort of database querying that results in more than one record (and maybe even then) I recommend using the querytoclass() function instead of query(). Its faster, and can query all the fields at once. To learn more, please do a search of this site for "querytoclass". You will find a number of articles showing how to use it. Link to comment Share on other sites More sharing options...
kanber Posted June 22, 2009 Author Share Posted June 22, 2009 querytoclass() function is ok. it is really faster. thank you. But I ask also for columns name lenght is just 10. but my variables big than 10 like above. logging.ARIZALAR.AddChannel("Device1MWBaslamaDakika_In",6) what can I do? Link to comment Share on other sites More sharing options...
AzeoTech Posted June 22, 2009 Share Posted June 22, 2009 I do not believe there is a limit on the name length. However, you might consider skipping the logging set altogether and use the db.execute() function with some SQL to put your data into the database directly. It gives you more control and flexibility Link to comment Share on other sites More sharing options...
kanber Posted June 23, 2009 Author Share Posted June 23, 2009 Hello, I attached file and database. Can you check for me? is there a limit or I am doing somethnig wrong? and can you give example about execute function thank you TEST2.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted June 23, 2009 Share Posted June 23, 2009 There is no limit in DF, but there could be in your database. Either switch databases (why are you using dBase?) or make your names shorter. As for execute, it works just like query() or querytoclass() except is for SQL commands that don't return a result set. I can't give an exact example because SQL dialects vary across databases, but something like this: db.execute(handle, "insert into ....") Link to comment Share on other sites More sharing options...
kanber Posted June 25, 2009 Author Share Posted June 25, 2009 there is no option in database to set lenght. I also try table name in daqfactory. I write "1234567890". then check the name and I see name is "12345678" what is the reason I dont understand... Link to comment Share on other sites More sharing options...
kanber Posted June 25, 2009 Author Share Posted June 25, 2009 I am trying to do write to database which I create in sqlserver. I do in ODBC settings also. and I can read data from columns. here is the code; private handle private string result var.History = 0 v.start2.ClearHistory() handle = db.Open("kanbersqlserver") result = db.QueryToClass(handle, "select * from kitap") ? result.kitapID v.start2 = result.kitapID db.close(handle) var.History = numrows(v.start2) but I want to change data or add new data to columns. how can I do in daqfactory? Link to comment Share on other sites More sharing options...
AzeoTech Posted June 25, 2009 Share Posted June 25, 2009 This is where the db.execute() function would be used along with the appropriate SQL commands. What the exact SQL commands are is a bit outside the scope of this forum. I recommend getting one of thousands of books of SQL. The functions you'll probably want are "Insert Into" and "update". I personally always refer to the MySQL web page, but then I usually use MySQL. If you are going to update a database, you are probably going to need to use db.execute() to add records (using Insert Into) instead of using a logging set. The table is probably going to need an autoincrement field. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.