SyncFusion to SQL connection and showing on the Dashboard - syncfusion

I just wanted to know whether there is a possibility to connect to the SQL table using SyncFusion, and display the table in the form of a pivot in the Front end. I am using TypeScript for coding. I can also use C# if I need to use. If yes let me know how can I create connection between the SyncFusion and the SQL Table.
Any help on this is appreciated.
Thanks in advance.
Regards,
Raja

The connection to SQL using SyncFusion can be achieved by using the below code snippet.
DataSet ds = new DataSet();
//In below provide full path of your database(*.sdf) location.
string conStringforDB = HttpContext.Current.Server.MapPath("Northwind.sdf").Split(new string[] { "\\wcf" }, StringSplitOptions.None)[0] + "\\Northwind.sdf";
SqlCeConnection con = new SqlCeConnection(conStringforDB);
con.Open();
SqlCeCommand cmd = new SqlCeCommand(#"SELECT Top(100) [Order ID], [Product ID], [Unit Price], Quantity
FROM [Order Details] ", con);
SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
da.Fill(ds);
//Creation of DataView
DataView dataView = new DataView(ds.Tables[0]);

Related

how to use db name as input control/parameter in jasper report

I am using jasper reports and want to give user to select the db name as input control and want to use that in query.
tool used is ireport /jasper soft studio 6.x
Got the solution for above question I used list of input control and then used the parameter value as
$P!{parametername}
Same as usage of table name as parameter/input control in jasper.
If I am understanding correctly, following code might help you.
Ofcourse "foo DB" and "baz DB" should have same tables.
Connection conn;
// Change the DB depend on input value.
if (userInput.equals("foo")){
conn = DriverManager.getConnection("jdbc:mysql://localhost/foo", "user", "password");
}
else if (userInput.equals("baz")){
conn = DriverManager.getConnection("jdbc:mysql://localhost/baz", "user", "password");
}
else{
// error
}
JasperReport jasper = (JasperReport)JRLoader.loadObject(your_jasper_filePath);
Map paramMap = new HashMap();
paramMap.put("param1", "some_param1");
paramMap.put("param2", "some_param2");
JasperPrint print = JasperFillManager.fillReport(jasper, paramMap, conn);
JasperExportManager.exportReportToPdfFile(print, PdfPath);

iDB2Commands in Visual Studio 2010

These are the basic things I know about iDB2Commands to be used in Visual Studio 2010. Could you please help me how could I extract data from DB2? I know INSERT, DELETE and Record Count. But SELECT or Extract Data and UPDATE I don't know.
Imports IBM.Data.DB2
Imports IBM.Data.DB2.iSeries
Public conn As New iDB2Connection
Public str As String = "Datasource=10.0.1.11;UserID=edith;password=edith;DefaultCollection=impexplib"
Dim cmdUpdate As New iDB2Command
Dim sqlUpdate As String
conn = New iDB2Connection(str)
conn.Open()
'*****Delete Records and working fine
sqlUpdate = "DELETE FROM expusers WHERE username<>#username"
cmdUpdate.Parameters.Add("username", iDB2DbType.iDB2Date)
cmdUpdate.Parameters("username").Value = ""
'*****Insert Records and working fine
sqlUpdate = "INSERT INTO expusers (username, password, fullname) VALUES (#username, #password, #fullname)"
cmdUpdate.Parameters.Add("username", iDB2DbType.iDB2VarChar)
cmdUpdate.Parameters.Add("password", iDB2DbType.iDB2VarChar)
cmdUpdate.Parameters.Add("fullname", iDB2DbType.iDB2VarChar)
cmdUpdate.Parameters("username").Value = txtUsername.Text
cmdUpdate.Parameters("password").Value = txtPassword.Text
cmdUpdate.Parameters("fullname").Value = "Editha D. Gacusana"
'*****Count Total Records and working fine
Dim sqlCount As String
Dim cmd As New iDB2Command
sqlCount = "SELECT COUNT(*) AS count FROM import"
cmd = New iDB2Command(Sql, conn)
Dim count As Integer
count = Convert.ToInt32(cmd.ExecuteScalar)
'*****Update Records and IT IS NOT WORKING AT ALL
sqlUpdate = "UPDATE expusers SET password = #password WHERE RECNO = #recno"
cmdUpdate.Parameters.Add("recno", iDB2DbType.iDB2Integer)
cmdUpdate.Parameters.Add("password", iDB2DbType.iDB2VarChar)
cmdUpdate.Parameters("recno").Value = 61
cmdUpdate.Parameters("password").Value = txtPassword.Text
cmdUpdate.Connection = conn
cmdUpdate.CommandText = sqlUpdate
cmdUpdate.ExecuteNonQuery()
conn.Close()
Please help me how to code the SELECT query wherein I could extract/fetch data from DB2 Database. Also, how could i update the records in the database.
Thanks!
Instead of ExecuteNonQuery(), look at ExecuteReader(). I don't have VS2010 installed, but try something like this:
iDB2Command cmdSelect = new iDB2Command("SELECT username, password, fullname FROM expusers", conn);
cmdSelect.CommandTimeout = 0;
iDB2DataAdapter da = new iDB2DataAdapter(cmdSelect);
DataSet ds = new DataSet();
da.Fill(ds, "item_master");
GridView1.DataSource = ds.Tables["expusers"];
GridView1.DataBind();
Session["TaskTable"] = ds.Tables["expusers"];
da.Dispose();
cmdSelect.Dispose();
cn.Close();
See: http://gugiaji.wordpress.com/2011/12/29/connect-asp-net-to-db2-udb-for-iseries/
If you aren't trying to bind to a grid, look at iDB2Command.ExecuteReader() and iDB2DataReader()
The DELETE is working fine? The code has the parameter type for "username" set to iDB2Date. The INSERT has "username" set to iDB2VarChar. How is the column defined in the table? Char, Varchar or Date?
On the UPDATE, you reference RECNO, but that does not seem to be a column in the table. Updating a relational database table by row number is a bad idea - the row numbers are not guaranteed to stay constant. If you are just testing, as I think you are, don't use RECNO, use RRN(). The DB2 for i syntax is WHERE rrn(expusers) = #recno
To help your testing, do a SELECT without a WHERE clause and list out all the rows. Make sure the name stored in the username column matches the name you are trying to update. Pay particular attention to the case of the data. If the name in expusers looks like "EDITHA D. GACUSANA", and #username is "Editha D. Gacusana" then it will not match on the WHERE clause.

WebMatrix 3 - WebGrid and ADO.NET Dataset with DB2

I'm querying a DB2 server using WebMatrix. I figured it would be easier for quick, proof of concept related tasks... but using DB2 rather than its built-in providers has been challenge, to say the least.
I know my results are coming back since I can iterate thru my dataset just fine and see my results.
I'm trying to use the built-in WebGrid() function within WebMatrix to display my results and keep getting errors:
CS1502: The best overloaded method match for
'System.Web.Helpers.WebGrid.WebGrid(System.Collections.Generic.IEnumerable,
System.Collections.Generic.IEnumerable, string, int, bool,
bool, string, string, string, string, string, string, string)' has
some invalid arguments
My code is basically:
OleDbConnection conn = new OleDbConnection(connString);
DataTable td = new DataTable;
OleDbDataAdapter da = new OleDbDataAdapter("SELECT USER, GROUP FROM DBO.TEST", connString);
ds = new DataSet();
da.Fill(ds);
var results = new WebGrid(ds.Tables[0].Rows);
Of course, its failing on:
var results = new WebGrid(ds.Tables[0].Rows);
Any help or direction would be appreciated. I'm assuming I need to convert this to a System.Collections.Generic.IEnumerable, but no idea how to accomplish this...?
You can't pass a DataTable into a WebGrid. The WebGrid wants an Enumerable that has public properties that it can use as column names. What you can do is to use Linq To DataSet to project the content of the DataTable into a more suitable form. The WebGrid will accept an anonymous type:
OleDbConnection conn = new OleDbConnection(connString);
DataTable td = new DataTable;
string query = #"SELECT USER, GROUP FROM DBO.TEST";
OleDbDataAdapter da = new OleDbDataAdapter(query, connString);
da.Fill(dt);
var data = dt.AsEnumerable().Select(r => new {
User = r.Field<string>("USER"),
Group = r.Field<string>("GROUP")
});
WebGrid results = new WebGrid(data);

SAP Crystal reports for VS 2010. Change the query at run time

I am using SAP CR for VS 2010 in C sharp. i have five tables and i am linking them with the following query:
query = "SELECT Items.AccessionNo, Items.Name, Items.LocalName, Items.Usage, Items.Province, Items.District, Items.VillTown, Items.EthnicCommunity, Arts.Name, Items.PurchasedDonated, Items.PurchasedFrom, Items.YearOfCollection, Items.Material, Items.Height, Items.Width, Items.Length, Items.Circumference, Items.Diameter, Items.Color, Items.Age, Items.Weight, Items.PurchasedValue, Items.Rare, Items.LivingDyingTrad, Items.ManufacturingProcess, Items.PlaceOfManufacturing, Items.ConditionReport, Items.Recommandations, Items.DateOfAddition, Items.Placement, Donators.Name, Collectors.Name, Placement.Name FROM Items INNER JOIN Arts ON Items.ArtId=Arts.ArtId INNER JOIN Donators ON Items.DonatorId=Donators.id INNER JOIN Collectors ON Items.CollectorId=Collectors.id INNER JOIN Placement ON Items.PlacementId=Placement.id WHERE Items.id=" + itemid;
The problem is that the report still shows up multiple results using the already embedded query at the time of design.
I am using the following code to pass the above query
SqlCommand cmd = new SqlCommand(query, dbconn.conn);
if (dbconn.conn.State == ConnectionState.Closed)
{
dbconn.conn.Open();
}
SqlDataAdapter Datadpt = new SqlDataAdapter(cmd);
DataSet dtset = new DataSet("items");
Datadpt.Fill(dtset);
//rep is the Report document object already defined
rep.Load(#"..\..\Reports\CRItem.rpt");
rep.SetDataSource(dtset);
CRViewer.ReportSource = rep;
if (dbconn.conn.State == ConnectionState.Open)
{
dbconn.conn.Close();
}
this.CRViewer.RefreshReport();
Any suggestions?
whoooosss.....i got it. the the crystalreportviewer selection formula is separate from report document record selection formula. Record Selection Formula that you've created in crystal report is stored in ReportDoc.RecordSelectionFormula property. When you load your ReportDoc to ReportViewer it doesn't adopt the value of .RecordSelectionFormula to its ReportViewer.SelectionFormula property. so what i did is....
My objects are:
ReportDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument
ReportViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer
FlexReportDoc.SetParameterValue("Reference", gsReference)
After passing necessary parameters if you have any...
ReportViewer.ReportSource = FlexReportDoc
ReportViewer.SelectionFormula = FlexReportDoc.RecordSelectionFormula
you need to assign the value of FlexReportDoc.RecordSelectionFormula property to ReportViewer.SelectionFormula.

Sync Services Ado.net SyncSchema

I'm trying to build a custom ServerSyncProvider
right now. I'm trying to understand the GetScema Method.
I'm trying to build a dataSet and associate it to SyncSchema class
one of my table columns is a nvarchar(50).
Here is what I'm doing this:
DataColumn column = new DataColumn();
column.ColumnName = "Name";
column.DataType = typeof(String);
column.MaxLength = 55;
table.Columns.Add(column);
But it turns out that on my client side, this column becomes nvarchar(1)
any idea?
Thanks a lot for helping me.
Use this code:
column.ExtendedProperties.Add("ColumnLength", 50);