0

Ten tools in 10 minutes

by Syed Aziz ur Rahman 11. June 2005 04:53
Just find this blog on weblogs.asp.net. Posting it here so that who missed it there get it from here .Scott Hanselman collection of useful tools.

Tags:

DotNet | ASP.Net | ASP.Net | DotNet

3

My First WebPart for Share Point

by Syed Aziz ur Rahman 14. May 2005 04:34
Ahhhhhh. After seven hours of doing just one thing i am tired and frustated. Doing developemt on a virtual PC is a headache, so slow. My be I should upgrade my PC. I have started learning sharepoint nowadays and today I made my first web part. I tried to upload the web part following the same steps in the MSDN article but alas. As soon as i try to drag and drop my webpart on the page, an error comes that this web part is not registed as safe. I have spent hours on just registring it as safe but no success. I donot know what i am doing wrong. May be I am too tired right now to see the mistake. I will see it tomorrow with a fresh mind. I will let you know about my foolish mistake if I find one.. Words under frustation.

Tags:

DotNet | ASP.Net | ASP.Net | DotNet

0

Problem in System.Random

by Syed Aziz ur Rahman 4. May 2005 07:46

What will be your condition if you are not able to find the bug using debugging? Same happen to me and I spent nearly 2 hours in just catching the bug.

Actually my task was to generate a random time table based upon certian business rules. I used System.Random for this but after some time i come to know that it is not so random :) . When i debug the application, it generated a differnt random number but as soon as I Perss F5 in VS.net, thinking it is working fine, it starts giving repeated numbers. I was not even suspecting the Random class and continously checking the bug in business logic.

Suddenly i got a idea that may be the random generation is some how related to time. I check the random number generation seperately and problem was still there. I put the thread to sleep for 100 millisecond before next generation and walaaaa..it works.

I checked the documentation but it is not mentioned there the algo of generation is anyhow related to time. May be someone else know. If it is so, please let me know..

 

Tags:

DotNet

0

Microsoft GDC 2005 (Gulf Developer Conference)

by Syed Aziz ur Rahman 16. April 2005 09:34

Finally GDC 2005 is over. It was a 3 days seminar from 9 to 6 covering different areas of Microsoft Technology. Microsoft put a lot of stress of smart client technology. There were sessions on Servers like CMS, Sharepoint, BizTalk etc. Speakers were from different countries including Pakistan as well. I was really shocked to see the number of local people there. It is a comman belief in foreigners like us that locals saudis are not so good in technology. Good to see that they are coming forward.

The quality of sessions were not as good as in PDC (in Pak), but of course something is better than nothing ;)

Tags:

DotNet

0

How to generate web forms in a good way?

by Syed Aziz ur Rahman 10. February 2005 03:44

We, in our software house, use a custom build code generator (thanx to my friend Syed Umar Anis).  It generates stored procedures, and (some what intelligent) business classes using the database schema. I want to extend this generator and want it to generate web forms as well.

I was thinking about some way so that i have to do minimal work and should be a flexible solution so that it remains compatilbe with the next version of web server controls.

I started by searching how to get the XML in aspx pages i.e. when we drag and drop some control like textbox on a aspx page, its xml will automatically be generated by the visual studio. i was searching for some method that i can do it programatically e.g.

dim txtName as textbox
txtName.Id = “txtName”
txtName.Width = “250”

these lines shoule “somehow” generate xml like this
<asp:textbox id=txtName runat=server Widht=250px></asp:TextBox>

the server control has a render method but it will give the HTML like
<input type=text ......

It seems that i have to do it manually. Anybody have some good idea? OR good solutionjQuery152012277863352197138_1327390651601
Waiting for replies and searching and thinking of a solution

Allah Hafiz

 

Tags:

ASP.Net | DotNet

1

Passing Parameters to Stored Procedures

by Syed Aziz ur Rahman 20. July 2004 23:33

Reports that use stored procedures as their data source are no different than reports that use any other data source. When you open the report, it automatically calls the stored procedure, retrieves the data, and populates the report with this data. The difference between using a stored procedure and using a table is that stored procedures accept parameters as input.

When a report is designed to get its data from a stored procedure, Crystal Reports examines the stored procedure to see if it requires parameters. If so, the designer automatically creates a report parameter that corresponds to each parameter in the stored procedure. There is a one-to-one mapping of report parameters to the parameters in a stored procedure. When the report runs, the report engine takes the value of each of these parameters and automatically passes them to the stored procedure.

As you know, the user is always prompted to enter the parameters before the report can execute. Of course, you probably don't want to prompt the user for this information because your application has already done so via the user interface. To prevent this from happening, manually populate the parameter(s) via code with the information the user has already provided.

Caution! Crystal Reports can't connect to stored procedures that have output parameters defined. When attempting to do so, the report returns the error "Failed to open a rowset" and doesn?t display any data.

Listing shows how to use the viewer control to populate the paramter fields that will be passed to the stored procedure.

Private Sub SpWithViewer(ByVal UserId As String, ByVal Password As StringByVal SpParameter As String)    'Logon to the server
    Dim crReport As New CustomerSP()
    Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
    Dim crLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo()
    CrystalReportViewer1.LogOnInfo = New CrystalDecisions.Shared.TableLogOnInfos()
    crLogonInfo.TableName = "spCustomers;1"

    With crLogonInfo.ConnectionInfo
        .ServerName = "(local)"
        .DatabaseName = "Northwind"
        .UserID = UserId
        .Password = Password
    EndWith

    CrystalReportViewer1.LogOnInfo.Add(crLogonInfo)
    'Create the parameter
    Dim ParameterFields As CrystalDecisions.Shared.ParameterFields
    Dim ParameterField As CrystalDecisions.Shared.ParameterField
    Dim ParameterRangeValue As CrystalDecisions.Shared.ParameterRangeValue
    Dim spValue As CrystalDecisions.Shared.ParameterDiscreteValue

    ParameterFields = New CrystalDecisions.Shared.ParameterFields()
    ParameterField = New CrystalDecisions.Shared.ParameterField()
    ParameterField.ParameterFieldName = "@CustPattern"
    spValue = New CrystalDecisions.Shared.ParameterDiscreteValue()
    spValue.Value = SpParameter
    ParameterField.CurrentValues.Add(spValue)
    ParameterFields.Add(ParameterField)
    CrystalReportViewer1.ParameterFieldInfo = ParameterFields

    'Show the report
    CrystalReportViewer1.ReportSource = crReport

End Sub

The first half logs onto the data source with the appropriate server name, database name, and login credentials. Notice that the TableName property is the name of the stored procedure with ?;1? shown at the end of it. This is how Crystal Reports identifies the stored procedures and you have to remember to include it as part of the table name. The second half of the code creates a new parameter field, adds is to the parameter fields collection and assigns this collection to the report viewer.You can also pass parameter using the ReportDocument object

Tip: If you want to pass a NULL value to a stored procedure parameter, set the parameter's Value property to Nothing in VB.Net and null in C#.

SET NOCOUNT ON

Although this section assumes you already familiar with stored procedures, there is one statement that doesn't get much attention but is very important.

SET NOCOUNT ON

If you are working with simple stored procedures, then the majority of them consist of a SELECT statement followed by a list of tables, fields and a join method. Crystal Reports handles this type of stored procedure fine. Once you start getting into writing more complex stored procedures you will find that you often need to execute multiple SQL statements within one stored procedure. This can happen when you are using temporary tables, and updating data prior to executing the final SELECT statement.

SET NOCOUNT ON
INSERT INTO AuditLog
SELECT * FROM tblSales WHERE

In the above code, the SET NOCOUNT ON statement is commented out. Running this code will generate two output messages for each statement. They will be in the format of ?xx records affected?. This message is passed prior to the records being returned from the stored procedure. This conflicts with what the report is expecting. Thus, it doesn't use the data from the SELECT statement as its resultset. By uncommenting the first line of code, you tell the database server not to report how many records are affected. This eliminates Crystal Reports from incorrectly using these messages as part of the database. Ideally, this statement would be the first statement in every stored procedure.

HTH

 

Tags:

ASP.Net | DotNet

1

Changing Sql Connection dynamically in Crystal Reports 10 using DotNet

by Syed Aziz ur Rahman 20. July 2004 01:12

Dim

myReport As New crDB()
myReport.SetDatabaseLogon(Me.txtUserId.Text, Me.txtPass.Text, Me.txtServer.Text, Me.txtDB.Text)
Dim myLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim myTable As CrystalDecisions.CrystalReports.Engine.Table

For
Each myTable In myReport.Database.Tables
   myLogonInfo = myTable.LogOnInfo
   With myLogonInfo.ConnectionInfo
      .ServerName = Me.txtServer.Text
      .DatabaseName = Me.txtDB.Text
      .UserID = Me.txtUserId.Text
      .Password = Me.txtPass.Text
  End With

   Try
     
myTable.ApplyLogOnInfo(myLogonInfo)
   Catch
     
MessageBox.Show("Login Failed")
      Exit
Sub
   End Try

   'Note: The next line is only necessary for SQL Server
  
myTable.Location = myTable.Location.Substring(myTable.Location.LastIndexOf(".") + 1)
Next myTable
CrystalReportViewer1.ReportSource = myReport

A very important piece of code is the assignment of the myTable.Location property (near the end of the listing). A requirement for changing the data source of a SQL Server table is that you must also change the Location property of the Table object. The Location property is a string value that has the name of the server as part of the string. It lists the database name, the table owner and the table name. For example, it looks similar to the following:

pubs.dbo.Customers

If you leave the Location property alone and don?t overwrite it, then the report?s server and database name won?t change. Instead, you have to reset it to just the table name. By removing the database name from the string, the report has to look at the new properties you just set to get this information. Consequently, this results in the server and database changing.

The easiest change to make would be to overwrite the Location property with a string constant. For example, the following line of code would overwrite it with the ?Customers? table.

myTable.Location = "Customers"

This works fine if the report only uses one table. But when you have multiple tables, you have to get more creative because you can?t assign the same table name to every table object. Rather than use a string constant, the code parses out the table name from the Location property and reassigns it to itself. This has the effect of resetting the value, but dropping the database name and table owner from the string.

myTable.Location = myTable.Location.Substring(myTable.Location.LastIndexOf(".") + 1)

HTH

 

 

Tags:

ASP.Net | DotNet | SqlServer

0

Create FTP and Web IIS Virtual Directory programmatically

by Syed Aziz ur Rahman 14. July 2004 03:33

Once there was a requirement in our project that user should be able to create his own website on our server by just clicking using our web application. Creating such type of wizard was not a hard task but i was thinking that if it is possible to create virtual directories in IIS “programmitically.

Then i opened my favorite webpage www.google.com  :) and start searching for a solution. Fortunately i found an article and here it is http://www.c-sharpcorner.com/Code/2002/July/CreateVirtualDirs.asp

Enjoy.

 

Tags:

DotNet

Powered by BlogEngine.NET 2.5.0.6
Original Design by Laptop Geek, Adapted by onesoft