declare
@NewCollation varchar(255)
,@Stmt nvarchar(4000)
,@DBName sysname
set @NewCollation = 'SQL_Latin1_General_CP1256_CI_AS' -- change this to the collation that you need
set @DBName = DB_NAME()
declare
@CName varchar(255)
,@TName sysname
,@OName sysname
,@Sql varchar(8000)
,@Size int
,@Status tinyint
,@Colorder int
declare curcolumns cursor read_only forward_only local
for select
QUOTENAME(C.Name)
,T.Name
,QUOTENAME(U.Name) + '.' +QUOTENAME(O.Name)
,C.Prec
,C.isnullable
,C.colorder
from syscolumns C
inner join systypes T on C.xtype=T.xtype
inner join sysobjects O on C.ID=O.ID
inner join sysusers u on O.uid = u.uid
where T.Name in ('varchar', 'char', 'text', 'nchar', 'nvarchar', 'ntext')
and O.xtype in ('U')
and C.collation != @NewCollation
and objectProperty(O.ID, 'ismsshipped')=0
order by 3, 1
open curcolumns
SET XACT_ABORT ON
begin tran
fetch curcolumns into @CName, @TName, @OName, @Size, @Status, @Colorder
while @@FETCH_STATUS =0
begin
set @Sql='ALTER TABLE '+@OName+' ALTER COLUMN '+@CName+' '+@TName+ isnull ('('
+CASE @Size WHEN -1 then 'max' else convert(varchar,@Size) end+')', '') +' COLLATE '+ @NewCollation
+' '+case when @Status=1 then 'NULL' else 'NOT NULL' end
--exec(@Sql) -- change this to print if you need only the script, not the action
PRINT @Sql
fetch curcolumns into @CName, @TName, @OName, @Size, @Status, @Colorder
end
close curcolumns
deallocate curcolumns
commit tran
Windows 7 still shows old icons after change! I found a solution but I don't think it's the best but it works.
Close all folders that are currently open.
- Press CTRL+SHIFT+ESC key sequence
- Right-click on the Explorer.exe process and kill it by selecting End Process.
- At File menu of Task Manager, select New Task (Run…)
- Type CMD.EXE, and click OK
- At thePrompt window, type the commands line by line and press ENTER after each command:
CD /d %userprofile%\AppData\Local DEL IconCache.db /a EXIT
- In Task Manager, click File, select New Task (Run…)
- Type EXPLORER.EXE, and click OK.
The key is that you must add the all radiobuttons to your radajaxmanager updated controls. somthing like this
ajaxManager.AjaxSettings.AddAjaxSetting(rbtn1, ddl, pnlLoading); ajaxManager.AjaxSettings.AddAjaxSetting(rbtn1, rbtn2, null); ajaxManager.AjaxSettings.AddAjaxSetting(rbtn1, rbtn1, null); ajaxManager.AjaxSettings.AddAjaxSetting(rbtn2, ddl, pnlLoading); ajaxManager.AjaxSettings.AddAjaxSetting(rbtn2, rbtn2, null); ajaxManager.AjaxSettings.AddAjaxSetting(rbtn2, rbtn1, null);
This will solve the problem. because after every postback all the dropdowns must updated.
Add following code to your radmenu control. replace targetfieldname with your field.
<DataBindings>
<telerik:RadMenuItemBinding TargetField="TargetFieldName" />
</DataBindings>
When you save a table in Management Studio that requires the table be dropped and recreated behind the scenes, the change will fail by default with the below warning. In SQL Server, tables are dropped, recreated and reloaded automatically for you without having to worry about what's going on behind the curtains but this may create issues for some users. This behavior is required upon a number of actions but most common is creating a new column in a specific location in the table. Warning Message: Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created. To fix this in Management Studio, go to Tools -> Options then go to the Designer Page and uncheck "Prevent saving changes that require table re-creation".
The problem is that when clicking on the checkbox/radiobutton, then the vertical scrollbar jumps to the top!
This could happen in some scenarios because of the way RadFormDecorator styles checkboxes. When RadFormDecorator is used, the real checkboxes are hidden outside of the viewport. When the decorated checkbox is clicked however, browsers try to focus the real checkbox, hence the "jumping". To avoid that, the only thing that you usually need to do is to set position:relative to the parent container.
In this case however, because of the RTL mode, the approach is a bit different and need to add the following CSS the page:
input.rfdRealInput { display:block; position: static !important; float: right; outline: 0; width: 0; height: 0; margin-top: -5px; FILTER: alpha(opacity=0); -moz-opacity: 0; opacity: 0 }
To load types in other assembly just add the assemblyname via comma at the end of your type: Type mytype = Type.GetType("Class2, Project2.Library "); for nested class you must put plus (+) instead of dot (.): Type mytype = Type.GetType("Class2+SubClass1, Project2.Library ");
foreach (myEnum item in Enum.GetValues(typeof(myEnum)))
{
...
}
public int GetOrdinal(string tableName, string name)
{
DataView schema = GetSchemaTable().DefaultView;
schema.RowFilter = String.Format("BaseTableName='{0}' AND ColumnName='{1}'", tableName, name);
if (schema.Count > 0)
return Convert.ToInt32(schema[0]["ColumnOrdinal"]);
else
throw new IndexOutOfRangeException();
}
Check this method in your constructor class. this will give you parent class type. Type callingClass = new System.Diagnostics.StackFrame(1).GetMethod().DeclaringType;
to solve this problem do the following instructions:
- Browse to HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
- Add a DWORD value called TabProcGrowth with a value of 0
DECLARE @SQLString nvarchar (255), @ParmDefinition nvarchar (255)
DECLARE @rowsCount int DECLARE @tablename sysname, @Empty char (1)
DECLARE FindNONEmptyTables CURSOR READ_ONLY
FOR SELECT TABLE_SCHEMA+'.'+TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
OPEN FindNONEmptyTables
FETCH NEXT FROM FindNONEmptyTables INTO @tablename WHILE (@@fetch_status = 0) BEGIN
SET @SQLString = N' SELECT @rowsCount= COUNT(*) FROM ' + @tablename + '; IF EXISTS (SELECT * FROM ' + @tablename + ') set @Empty = ''N'' ELSE set @Empty = ''Y''' SET @ParmDefinition = N'@tablename sysname, @Empty char(1) OUTPUT, @rowsCount int OUTPUT'
EXECUTE sp_executesql @SQLString, @ParmDefinition, @tablename = @tablename, @Empty = @Empty OUTPUT, @rowsCount = @rowsCount OUTPUT
IF @Empty = 'N' BEGIN PRINT @tablename + ' rows count is :' + CAST (@rowsCount AS NVARCHAR(50)) END FETCH NEXT FROM FindNONEmptyTables INTO @tablename END
CLOSE FindNONEmptyTables DEALLOCATE FindNONEmptyTables GO
SELECT CONVERT(VARCHAR(10),GETDATE(),111)
you can use this method Request.IsSecureConnection
public static string Capitalize(string value)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value);
}
You use an *.asmx file to create an ASP.NET Web Service. This file contains your service implementation and is needed for hosting the service.
ASP.NET automatically generates the WSDL or "service description" for your service by reflecting over the types in your service. You can see the WSDL for your service by browsing to your ASMX file, which should show you a help page for your service containing a link to the service description for the service. The WSDL can also generally be reached by appending "?wsdl" to the address of the asmx file.
DateTime myDate = DateTime.MinValue; //=> 1/1/0001
SqlDateTime mySqlDate = SqlDateTime.MinValue; //=> 1/1/1753
//Note that SQL Server's smalldatetime min value is 1/1/1900
Response.ContentType = "application/force-download";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + Filename + "\"");
Response.BinaryWrite(yourbuffer);
Response.End();
if you want to shrink database log file just run this codes with your database name:
BACKUP LOG yourdbname WITH TRUNCATE_ONLY DBCC SHRINKFILE(yourdbname_log, 2)
this code will shrink and reduce your database log file to 2MB
A WPF browser project is the same as writing a java applet/application, only you use IE and .net instead. you would do it for the same reasons you would write a java application.
The main wpf cons are:
- User must have .net installed, and use IE to access the app.
- Slow load time (.net vm must be loaded and app jit'd)
the main wpf pros:
- Rich UI (winforms)
- Coding understood by windows programers
the main asp.net cons:
- Programmer must learn web model
- Somewhat limited UI
- Cross browser testing required
the main asp.net pros:
- Cross browser compatiability (universal access)
برای حل مشکل کافی است در بخش GlobalSection فایل sln خود خط زیر را اضافه کنید:
SccProjectEnlistmentChoice0 = 2
Copy and paste the following lines into a Notepad file.
[Shell] Command=2 IconFile=explorer.exe,3 [Taskbar] Command=ToggleDesktop
Rename it to desktop.scf
Run RemoteComponents.hta from your installation cds. navigate and find "install full remote debugging on all operating systems" and push the install full button. I had to many probems with my remote debugger and this solved my problem.
this link was very usefull to understand what is my debugger problem:
http://blogs.msdn.com/mkpark/articles/86872.aspx
SELECT TOP 1 * FROM TableName ORDER BY NEWID()
I got this strange error when tried to overwrite file. I had full control access but i got this error.
The error occured when the file is read only! change the attribute of existing file and you will be able to copy the file!
You can solve this problem with leave the controltovalidate property blank.
|
Sometimes the schema of a replicated table needs altering. There are many reasons this might be the case eg possibly the datatype has been incorrectly chosen, or a default is missing, or we want to rename a column. Attempting to change the table schema directly will result in the error
"Cannot alter/drop the table 'tablename' because it is being published for replication".
So, how to change an existing column without breaking replication? Consider if we wanted to make the following schema change:
to 
The method we choose depends in part on the replication type and size of the table, but there are 2 main options:
(a) altering the subscriptions exec sp_dropsubscription @publication = 'tTestFNames'
, @article = 'tEmployees'
, @subscriber = 'RSCOMPUTER'
, @destination_db = 'testrep'
exec sp_droparticle @publication = 'tTestFNames'
, @article = 'tEmployees'
alter table tEmployees alter column Forename varchar(100) null
exec sp_addarticle @publication = 'tTestFNames'
, @article = 'tEmployees'
, @source_table = 'tEmployees'
exec sp_addsubscription @publication = 'tTestFNames'
, @article = 'tEmployees'
, @subscriber = 'RSCOMPUTER'
, @destination_db = 'testrep'
For snapshot replication this is the obvious choice. We drop the subscription to this article, drop the article, then change the table. Afterwards the process is reversed. The next time the snapshot agent is run, it'll pick up the new schema without any issues.
For transactional replication we may choose to proceed using the script above. However, we must be more careful in this case. By default, an insert, update or delete statement performed on the publisher is propagated to the subscriber in the form of a stored procedure call. By changing the column definition, we may need to change the related stored procedures on all the subscribers. Addition of a default would be fine, but changing the datatype itself as above would require the stored procedure arguments to be modified. For the example table above, these 3 procedures exist on the subscriber in the form:
sp_MSins_tEmployees, sp_MSupd_tEmployees, sp_MSdel_tEmployees.
They can be generated at the publisher using sp_scriptpublicationcustomprocs but this would of course require the system to be quiesced, i.e. during this (quick) change there shouldn't be any alterations made to the publisher's data and all the subscribers should be completely synchronized.
This is not ideal, and there is also a hidden problem here waiting to be discovered. Usually, when you add a new article to an existing publication in transactional replication, running the snapshot agent will create a snapshot of just the new article. In our case, it'll also create a snapshot of the 'tEmployees' table. So, to avoid all the issues and complications mentioned above, it's simplest to run the snapshot agent immediately after executing sp_addsubscription and then synchronize.
In merge replication, there is no possibility of dropping the subscription on a per article basis using the script above, as there is in transactional and snapshot replication. If we drop the subscription entirely including all other articles (sp_dropmergesubscription), then try to run sp_dropmergearticle there will be an error if the snapshot has already been run, so we have to set @forceinvalid_snapshot to 1, make the table change on the publisher then read the article and subscriptions and initialize which would necessitate a new snapshot generation of all articles in this publication. A nosync initialization is possible, but this can be extremely restrictive for future changes, and I'll leave that for another article.
(b) altering the table in-placeOK, in some cases the table is large and we don't want to run a new snapshot - either of the individual table (transactional) or of the whole publication (merge) - so there is an alternative method. We might use the built in stored procedures sp_repladdcolumn and sp_repldropcolumn to make the changes (note that these procedures limit the subscribers to be SQL Server 2000 only). Using these procedures we can add a dummy column to hold the data, remove the old column, add in the correct definition of the original column then transfer back the data. Now the script becomes:
exec sp_repladdcolumn @source_object = 'tEmployees'
, @column = 'TempForename'
, @typetext = 'varchar(100) NULL'
, @publication_to_add = 'tTestFNames'
update tEmployees set TempForename = Forename
exec sp_repldropcolumn @source_object = 'tEmployees'
, @column = 'Forename'
exec sp_repladdcolumn @source_object = 'tEmployees'
, @column = 'Forename'
, @typetext = 'varchar(100) NULL'
, @publication_to_add = 'tTestFNames'
update tEmployees set Forename = TempForename
exec sp_repldropcolumn @source_object = 'tEmployees'
, @column = 'TempForename'
Although the above script can be used for transactional replication or merge replication, the internal methodology is different due to the differing nature of these 2 techniques. For merge replication, details of the rows updated are kept in MSmerge_contents, and if a particular row has been changed once or a hundred times, there will still only be one entry in this system table, while in transactional replication, 100 updates to a row is propagated as 100 subscriber updates. This means merge has an advantage over transactional because we need to perform 2 updates to each row to make the schema change. |
You can find the main article in: http://www.sqlservercentral.com/articles/Replication/alteringacolumnonareplicatedtable/1666/
Add your code in button click add this code (replace your link in the code) private void btn_Click(object sender, EventArgs e)
{
.....
StringBuilder script = new StringBuilder();
script.Append("<script>");
script.AppendFormat("window.open('{0}', '', '');", link);
script.Append("</scri");
script.Append("pt>");
Page.RegisterStartupScript("opennewwindow", script.ToString());
.....
}
public DataView GetTopDataViewRows(DataView source, int count)
{
DataTable output = source.Table.Clone();
for (int i = 0; i < count; i++)
{
if (i >= source.Count)
break;
output.ImportRow(source[i].Row);
}
return new DataView(output, source.RowFilter, source.Sort, source.RowStateFilter);
}
There are two ways :
-
EXEC sp_dboption 'pubs', 'single user', 'TRUE'
-
alter database pubs set SINGLE_USER WITH ROLLBACK IMMEDIATE To deactive single user mode :
EXEC sp_dboption 'pubs', 'single user', 'FALSE'
2- alter database pubs set MULTI_USER
just run sp_who stored procedure.
CREATE TABLE #TmpWho
(spid INT, ecid INT, status VARCHAR(150),
loginame VARCHAR(150), hostname VARCHAR(150),
blk INT, dbname VARCHAR(150), cmd VARCHAR(150))
INSERT INTO #TmpWho
EXEC sp_who
DECLARE @spid INT
DECLARE @getspid CURSOR
SET @getspid = CURSOR FOR
SELECT spid
FROM #TmpWho
WHERE dbname = 'YOURDBNAME'
OPEN @getspid
FETCH NEXT FROM @getspid INTO @spid
WHILE @@FETCH_STATUS = 0
BEGIN
KILL @spid --SELECT @spid works fine here
FETCH NEXT FROM @getspid INTO @spid
END
CLOSE @getspid
DEALLOCATE @getspid
DROP TABLE #TmpWho
If FLV files do not appear in the player and you get 404 error it means that you need to add a mime type for flv files.
add MIME-Type for .FLV extentions with the proper mime-type "flv-application/octet-stream"
- Create a virtual directory at the root of your default website
- Name the virtual WebAdmin
- Set the Path of the Virtual Directory to "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\ASP.NETWebAdminFiles" where 50215 is the appropriate build version for your installed .NET 2.0 framework.
- After the Virtual Directory has been created, right click on the Virtual Directory and got to properties. Select the ASP.NET tab and make sure the ASP.NET version is set to a 2.0 version.
- Open a browser and browse to the following url:
http://localhost/webadmin/default.aspx?applicationPhysicalPath=D:\wwwroot\timetracker\&applicationUrl=/Timetracker
- Make sure to change the applicationPhysicalPath and applicationUrl querystring parameters to match whatever they are on your system.
DECLARE @tableCatalog VARCHAR (1024) ,
@tableSchema VARCHAR (1024), @tableName VARCHAR (1024), @tableType VARCHAR (1024)
DECLARE cursorTemp CURSOR FOR
SELECT * FROM INFORMATION_SCHEMA.TABLES
OPEN cursorTemp
FETCH cursorTemp INTO @tableCatalog, @tableSchema, @tableName, @tableType
-- start the main processing loop.
WHILE @@Fetch_Status = 0
BEGIN
EXEC (' ALTER TABLE '+@tableName+' NOCHECK CONSTRAINT ALL;' +
' DELETE FROM '+ @tableName +';'+
' ALTER TABLE '+@tableName+' CHECK CONSTRAINT ALL ')
FETCH cursorTemp INTO @tableCatalog, @tableSchema, @tableName, @tableType
END
CLOSE cursorTemp
DEALLOCATE cursorTemp
Defferent between Stored procedure and User Functions
You change wrap property with white-space property in css. normal : Default. White-space is ignored by the browser pre : White-space is preserved by the browser. Acts like the pre tag in HTML nowrap : The text will never wrap, it continues
|