|
Server-side programming |
Top Previous Next |
|
With DbNetSuite there is no requirement for any server-side programming but if you do use AJAX calls to invoke server-side code then if you need to interface with the database you can use the DbNetLink.DbNetData database interface class to make this task simpler. The DbNetData class simplifies the process of connecting to the database by reducing the amount of code you need to write to create parameter driven queries and updates and also provides a common interface across all the supported databases. Selecting records using DbNetData
[WebMethod]
///////////////////////////////////////////////////////////////
public static string CreateCSV(string Filter)
///////////////////////////////////////////////////////////////
{
QueryCommandConfig Query = new QueryCommandConfig();
Query.Sql = "select * from products where discontinued = @discontinued";
Query.Params["discontinued"] = 1;
DbNetData Db = new DbNetData("SamplesDatabase");
Db.Open();
Db.ExecuteQuery(Query);
StringBuilder CSV = new StringBuilder();
while (Db.Reader.Read()) {
List
Updating records using DbNetData
[WebMethod]
///////////////////////////////////////////////////////////////
public static void UpdateProductRecords(string Filter)
///////////////////////////////////////////////////////////////
{
UpdateCommandConfig Update = new UpdateCommandConfig();
Update.Sql = "update products set discontinued = @disc where discontinued = @discontinued";
Update.Params["disc"] = 0;
Update.FilterParams["discontinued"] = 1;
DbNetData Db = new DbNetData("SamplesDatabase");
Db.Open();
Db.ExecuteUpdate(Update);
Db.Close();
}
|