Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Saturday, February 25, 2012

deploy to another server

I do not have access to VS, but I hear it can do this... how can I do it without VS?

I am using CREATE ASSEMBLY to load dll form my server to SQLServer on my server (Same machine). How can I load the dll to another server? Do I have to write it on a directory on that server first? I tried to run the command from my pc connected to the other server, and I get a "cannot find file" error.

The FROM clause in CREATE ASSEMBLY can either take a path to the dll (which is what you are doing), but it can also instead of the path take the binary representation of the dll.

So in your case, you can either use a path which the remote server accesses and has permissions to - or you can take the binary representation of the assembly instead.

Niels

|||Thanks. How do I do that binary representation? All the documentation I see is about the path to the dll. I'm new to .net development so I don't know where to go for help.|||

The syntax is

CREATE ASSEMBLY <asm_name> FROM 0x...

where 0x... is the hex binary representation.

The simplest way to get this is the use Management Studio. Choose the assembly in the object explorer, and click Script Assembly As -> Create To > New Query Editor Window. This will output the right syntax for you.

An alternative is code like below to convert the assembly to binary.

using System.IO;

using System;

using System.Text;

public class FileToHexBinary

{

public static void Main(String[] args)

{

FileStream fs = new FileStream(args[0], FileMode.Open);

int size = (int)fs.Length;

byte[] bytes = new byte [size];

fs.Read (bytes, 0, size);

fs.Close ();

StringBuilder builder = new StringBuilder(size * 2);

foreach( byte b in bytes)

{

builder.Append(b.ToString("x2"));

}

Console.WriteLine("0x" + builder.ToString());

}

}


|||Why b.ToString("x2")? What does the x2 mean? Whats the difference between "x" and "x2"?

Friday, February 17, 2012

Depending on the due date, start date and end date calculate the number of entries

Hi!
I am using SQl server 8.0 and I have a web form on which I have below controls or I can say below column in the TABLE A

DueDate
Start date
End Date
Interval -- Monthly or Quarterly
Amount

Depending on the Interval(Monthly or Quarterly) I want to make an entry in the Table B which will be fall between start date and end date and on due date

EXample

DueDate = 11/15/2005
Start date =11/01/2005
End Date =11/30/2006
Interval = Monthly
Amount = 2500

In the table I should have an 12 entry as
PaymentDate Amount
=======================
11/15/2005 2500
12/15/2005 2500
01/15/2006 2500
02/15/2006 2500
03/15/2006 2500
04/15/2006 2500 ....

Please advice

Thanks
AshikaIf you keep a table of numbers then you can do this easily. Ex:

-- assume that you have table called Numbers with numbers from say 0...8000.
insert into tbl (PaymentDate, Amount)
select dateadd(month, N, @.DueDate), @.Amount
from Numbers
where N between 0 and datediff(month, @.DueDate, @.EndDate);

Alternatively, you should have a calendar table in the system that is prepoulated with all the dates. You can then use it to generate the data easily. The calendar table also solves other problems related to maintaining different calendar types in the database, accounting for holidays etc. This is a common approach in data warehousing.