open up a connection to the MS SQL 2008 database using the connection string in layer->connection */ ie. "driver= ;server= ;database= ;integrated security=?;user id= ;password= " */
| 333 | /* open up a connection to the MS SQL 2008 database using the connection string in layer->connection */ |
| 334 | /* ie. "driver=<driver>;server=<server>;database=<database>;integrated security=?;user id=<username>;password=<password>" */ |
| 335 | int msMSSQL2008LayerOpen(layerObj *layer) |
| 336 | { |
| 337 | msMSSQL2008LayerInfo *layerinfo; |
| 338 | char *index, *maskeddata; |
| 339 | int i, count; |
| 340 | char *conn_decrypted = NULL; |
| 341 | |
| 342 | if(layer->debug) { |
| 343 | msDebug("msMSSQL2008LayerOpen called datastatement: %s\n", layer->data); |
| 344 | } |
| 345 | |
| 346 | if(getMSSQL2008LayerInfo(layer)) { |
| 347 | if(layer->debug) { |
| 348 | msDebug("msMSSQL2008LayerOpen :: layer is already open!!\n"); |
| 349 | } |
| 350 | return MS_SUCCESS; /* already open */ |
| 351 | } |
| 352 | |
| 353 | if(!layer->data) { |
| 354 | msSetError(MS_QUERYERR, DATA_ERROR_MESSAGE, "msMSSQL2008LayerOpen()", "", "Error parsing MSSQL2008 data variable: nothing specified in DATA statement.<br><br>\n\nMore Help:<br><br>\n\n"); |
| 355 | |
| 356 | return MS_FAILURE; |
| 357 | } |
| 358 | |
| 359 | if(!layer->connection) { |
| 360 | msSetError( MS_QUERYERR, "MSSQL connection parameter not specified.", "msMSSQL2008LayerOpen()"); |
| 361 | return MS_FAILURE; |
| 362 | } |
| 363 | |
| 364 | /* have to setup a connection to the database */ |
| 365 | |
| 366 | layerinfo = (msMSSQL2008LayerInfo*) msSmallMalloc(sizeof(msMSSQL2008LayerInfo)); |
| 367 | |
| 368 | layerinfo->sql = NULL; /* calc later */ |
| 369 | layerinfo->row_num = 0; |
| 370 | layerinfo->geom_column = NULL; |
| 371 | layerinfo->geom_column_type = NULL; |
| 372 | layerinfo->geom_table = NULL; |
| 373 | layerinfo->urid_name = NULL; |
| 374 | layerinfo->user_srid = NULL; |
| 375 | layerinfo->index_name = NULL; |
| 376 | layerinfo->conn = NULL; |
| 377 | |
| 378 | layerinfo->conn = (msODBCconn *) msConnPoolRequest(layer); |
| 379 | |
| 380 | if(!layerinfo->conn) { |
| 381 | if(layer->debug) { |
| 382 | msDebug("MSMSSQL2008LayerOpen -- shared connection not available.\n"); |
| 383 | } |
| 384 | |
| 385 | /* Decrypt any encrypted token in connection and attempt to connect */ |
| 386 | conn_decrypted = msDecryptStringTokens(layer->map, layer->connection); |
| 387 | if (conn_decrypted == NULL) |
| 388 | { |
| 389 | return(MS_FAILURE); /* An error should already have been produced */ |
| 390 | } |
| 391 | |
| 392 | layerinfo->conn = mssql2008Connect(conn_decrypted); |
nothing calls this directly
no test coverage detected