paul_9999 - Monday, July 26, 2010 10:25 AM:
I'm probably being thick but....
I have been trying ( all day ) to write a very simple method to write to an external SQL database.
All would seem good but how do I change the login credentials that innovator uses when it tries to connect to the external db?
By default It seems to connect using the aras_innovator user name.
The db is on the the same SQL_server instance.
DavidSpackman - Tuesday, July 27, 2010 6:14 AM:
HI Paul
Did you use the SqlConnection class to set up your ConnectionString properties?
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx
Here is an example of some code I have used
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection( "user id=sa;" + "password=Your_Details;" + "server=Your_Details;" +
"database=Your_Details; " +
"connection timeout=10");
conn.Open();
paul_9999 - Tuesday, July 27, 2010 8:13 AM:
See, told you I was being thick ! I've used this stuff in vb.net before so that definately sends me to the bottom of the class.
Now I have that working, another question if I may.
If I wanted to do an SQL count. how do I get the result back? I can see that the result comes back as an item but do I really have to parse the xml to find the answer?
This is my first time using xml so forgive me if the answer is really simple !
Thanks for your help.
DavidSpackman - Tuesday, July 27, 2010 9:54 PM:
Hi Paul, not sure if I'm able to help with this one, I'm only new to it too :)
In my case I was returning SQL data as part of a federated item
To return the table data I used the SqlCommand / SqlDataReader Class, and I don't think it is possible to return the row count from a SqlDataReader member.
One way for it would be possible for me to get around that would be to run a separate SqlCommand / SqlDataReader object that just returns the count from my original query. The value will be returned as int and would be easy to write that back to the item
[SqlDataReader].Read()
String countValue = Convert.ToString([SqlDataReader].GetInt32(0));
[Item].setProperty([property],countValue);
Not sure if that is any help :)