need some help on mspjgrid

S

Sander

Hi I'm trying to use the MSPJGrid for making own reports/lists. I'm having
problems understanding the example that microsoft provides as it does not
make a connection to a database but is adding records to the record set
'manually'.
Can anybody help me with this?
I have modified the sample.htm to the function below, but it is not giving
me any data back on the page (the query is executed on the database seen in
profiler, so something is wrong in binding the data i guess):

function Init() {
var tekst;
var adUseClient = 3;
var adInteger = 3;
var adDate = 7;
var adBoolean = 11;
var adVarWChar = 202;
var Conn = new ActiveXObject("ADODB.Connection");
var rs = new ActiveXObject("ADODB.Recordset");
rs.CursorLocation = adUseClient;

var strSQL = "SELECT PROJ_ID, PROJ_NAME FROM MSP_WEB_PROJECTS WHERE
PROJ_ID =7";

Conn.Open("Provider=SQLOLEDB;Data
Source=localhost;Database=projectserver;integrated security=SSPI");
rs = Conn.Execute(strSQL);

MSPJGrid.Binding = rs;
MSPJGrid.FieldList = "PROJ_ID,PROJ_NAME";
MSPJGrid.Refresh();
MSPJGrid.Outlining = false;
MSPJGrid.Refresh();
MSPJGrid.GanttView = false;
MSPJGrid.Refresh();
}
 
T

tonyzink

Hi Sander --

The MSPJGrid control is a powerful tool for displaying custom views of
project information in PWA... if you can figure out how to use it! I've
used it to dig into the SharePoint database and retrieve & display
issues across all projects, with autofiltering, grouping, etc.; I've
taken my Init() function and modified it with your information...

========================================
function Init() {

var adUseClient = 3;
var adInteger = 3;
var adDate = 7;
var adBoolean = 11;
var adVarWChar = 202;

var rs = new ActiveXObject("ADODB.Recordset");
rs.CursorLocation = adUseClient;

rs.Fields.Append("PROJ_ID", adVarWChar, -1, 0);
rs.Fields.Append("PROJ_NAME", adVarWChar, -1, 0);
rs.Open();

var fieldnames = new Array();

fieldnames[0] = "PROJ_ID";
fieldnames[1] = "PROJ_NAME";

var fieldvalues = new Array();

var rst;
var dsn;
var sql;

rst = new ActiveXObject("ADODB.Recordset");
dsn = new ActiveXObject("ADODB.Connection");
dsn.Open ("Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=USERIDGOESHERE;Initial Catalog=DATABASENAMEGOESHERE;Data
Source=localhost;pwd=PASSWORDGOESHERE");
sql = "SELECT PROJ_ID, PROJ_NAME FROM MSP_WEB_PROJECTS WHERE
PROJ_ID=7";
rst.Open (sql, dsn);

while (!rst.EOF){

fieldvalues[0] = rst(0);
fieldvalues[1] = rst(1);
rs.AddNew(fieldnames, fieldvalues);

rst.moveNext();
}

rst.Close();
rs.Update();
MSPJGrid.Binding = rs;

MSPJGrid.FieldList = "PROJ_ID[Project ID],PROJ_NAME[Project Name]";

MSPJGrid.Outlining = false;
MSPJGrid.GanttView = false;
MSPJGrid.Refresh();
}
========================================

I haven't tested the code, so you may need to tweak it if it doesn't
work properly.

Also, I've changed your connection string (dsn.Open), so you'll need to
either (a) enter a username and password for a user who can access the
database (in my instance, I created a special database user who had
read-only access), or (b) change the connection string to meet your
needs.

Good luck!

Tony Zink
========================================
http://www.msprojectreporter.com
http://www.pmreporter.com
http://www.sharepointreporter.com
http://www.msofficereporter.com
http://www.dotnetreporter.com
========================================
 
S

Sander

Tony,

I think I understand what you did. thanks a lot, i should get going with it
now.

Sander
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top