Saturday, March 31, 2007

Saving large text to database field.

  1. System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
  2. MemoryStream mr = new MemoryStream();
    bf.Serialize(mr, strCode);
  3. byte[] bt = mr.GetBuffer();

assign this bt to the param.Value to be passed to the sqlhelper.

Retrieving a large text stored as binary in the database.

- SQLHelper.ExecuteScalar would return an object.
- System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf_1 = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
MemoryStream mr_1 = new MemoryStream(objClassCode as Byte[]);
//retrieve the code from the database and assign to the variable.
string strText = bf_1.Deserialize(mr_1).ToString();
mr_1.Close();

Friday, March 30, 2007

string.Join

it will recreate a single string from an array of string, give a separator to create string with separator.

Wednesday, March 21, 2007

Replace special characters in the file name

string strTest = "abcd@efg";
string strPattern = @"#/\?*#";
Regex rg = new Regex(strPattern);
if (rg.IsMatch(strTest))
{
//replaces invalid chars with __
_fileNameWithSpecialCharsReplaced = rg.Replace(value, "__");
}

Replace spaces with underscore in a string

using System.Text.RegularExpressions;

Regex reg = new Regex(@"\s");
string strTest = "hello how are you";
string strout = reg.Replace(strTest, "_");

Friday, March 16, 2007

DTS IMPORT / EXPORT GIVES ERROR

Resloved using the below solution.

Run the svrnetcn.exe on which MSDE is installed, SQL Server Network Utility Dialogbox will be displayed,Make sure that TCP/IP is enabled and the port is 1433.

Tuesday, March 13, 2007

MSDE Limitations

An MSDE database can be no larger than 2 GB (this includes MDF and NDF files only รข€” log sizes are not included in the size limit);

MSDE does not support SQL Mail

As of July 2004, these are the planned limitations of the next generation of MSDE, now known as SQL Server Express (which will still be a free product):
1 GB memory (for buffer, not total);
1 CPU;
50 named instances per machine;
4 GB per database (not including log files);

Monday, March 12, 2007

sql server utility to do bulk copy / insert

bcp "table name" out "file path" -S ServerName -U username -P Password -k -c -E -q
(see the bcp command help by typing bcp on command promp)

bcp seat_data_core out c:\core.txt -S DLG6BVV81 -U PodsUser -P pods -k -c -E -q
bcp seat_data_stage_2 out c:\stage2.txt -S DLG6BVV81 -U PodsUser -P pods -k -c -E -q
bcp seat_extra_data out c:\extra.txt -S DLG6BVV81 -U PodsUser -P pods -k -c -E -q


bcp seat_data_stage_2 in c:\stage2.txt -S usmitry-db09 -U PodsUser -P pods -k -c -E -q
bcp seat_extra_data in c:\extra.txt -S usmitry-db09 -U PodsUser -P pods -k -c -E -q