|
Hi,
I dont know the references for this code . please some one copy the code to VS2008 and check for the reference.
Thanks!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Management.Smo;
using System.Diagnostics;
using System.Collections.Specialized;
namespace Transfer2008To2005
{
class Program
{
static void Main(string[] args)
{
string sourceserver = "SourceServerName";
string destinationserver = "DestinationServerName";
Server src = new Server(sourceserver);
Server dest = new Server(destinationserver);
string[] myarray = new string[] { "databasename", "otherdbname" };
foreach (Database db in src.Databases)
{
if (db.IsSystemObject == false && db.Status == DatabaseStatus.Normal)
{
Debug.WriteLine("Now moving " + db.Name);
if (dest.Databases.Contains(db.Name))
dest.KillDatabase(db.Name);
Transfer t = new Transfer(db);
t.DestinationServer = destinationserver;
t.DestinationDatabase = db.Name;
t.CreateTargetDatabase = true;
t.PreserveDbo = true;
t.TargetDatabaseFilePath = "D:\\SQLDATA\\";
t.TargetLogFilePath = "F:\\SQLLOGS\\";
t.CopyAllDefaults = true;
t.CopyAllFullTextCatalogs = true;
t.CopyAllRoles = true;
t.CopyAllRules = true;
t.CopyAllSchemas = true;
t.CopyAllStoredProcedures = true;
t.CopyAllSynonyms = true;
t.CopyAllTables = true;
t.CopyAllUserDefinedDataTypes = true;
t.CopyAllUserDefinedFunctions = true;
t.CopyAllUserDefinedTypes = true;
t.CopyAllUsers = true;
t.CopyData = true;
t.CopySchema = true;
t.CopyAllObjects = false;
t.DropDestinationObjectsFirst = true;
t.Options.WithDependencies = true;
t.Options.IncludeDatabaseRoleMemberships = true;
t.Options.Indexes = true;
t.Options.DriAll = true;
t.Options.Permissions = true;
t.Options.SchemaQualify = true;
t.Options.SchemaQualifyForeignKeysReferences = true;
t.Options.Statistics = true;
t.Options.TargetServerVersion = SqlServerVersion.Version90;
t.Options.WithDependencies = true;
t.Options.IncludeIfNotExists = true;
t.Options.FullTextIndexes = true;
t.Options.ExtendedProperties = true;
t.TransferData();
t = new Transfer(db);
t.DestinationServer = destinationserver;
t.DestinationDatabase = db.Name;
t.DestinationLogin = "schemalogin";
t.DestinationPassword = "schemapassword";
t.DestinationLoginSecure = false;
t.CopyAllViews = true;
t.CopyAllTables = true;
t.CopyAllObjects = false;
t.CopyAllDatabaseTriggers = true;
t.Options.Triggers = true;
t.CopyData = false;
t.CopySchema = true;
t.Options.IncludeIfNotExists = true;
t.TransferData();
}
}
}
}
}
|
|
|
|
|
What do you mean by references in this context? If you have compile errors then post the text here and people will try to explain what is wrong.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
If you want to know what assemblies to reference, simply compile the code. The IDE will complain about the types that it cannot find. Most of these types will have a page on MSDN, and that page includes the name of the assembly that the type is located in. Add reference, compile again, find the next one.
Bastard Programmer from Hell
|
|
|
|
|
in .Net 3.5 versiyon i added those to references and i took buil succeeded.
Microsoft.SqlServer.Management.Smo
Microsoft.SqlServer.Management.Sdk.Sfc
Microsoft.SqlServer.Smo
Microsoft.SqlServer.SmoExtended
Microsoft.SqlServer.SqlEnum
it will work. but check clearly version when you add reference.
|
|
|
|
|
|
I have created a bool User Setting called ShowRecent with a value of True. I created it in the designer, and in app.config it shows as True.
I created a bool property:
public bool ShowRecent { get; set; }
I also created these two methods:
public void loadSettings()
{
ShowRecent = Properties.Settings.Default.ShowRecent;
}
public void saveSettings()
{
Properties.Settings.Default.ShowRecent = ShowRecent;
Properties.Settings.Default.Save();
}
I then run
engine.loadSettings();
engine.ShowRecent = true;
engine.saveSettings();
when the loadSettings is run the property is False. Even when I set it to True and called saveSettings, the propety is still False. app.config still has True.
What am I doing wrong here?
Everything makes sense in someone's mind
|
|
|
|
|
Settings aren't stored in app.config. They are stored in the user settings directory.
|
|
|
|
|
Mine is.
Opened app.config, there it is.
Remove the setting, reopen app.config - it's gone
Everything makes sense in someone's mind
|
|
|
|
|
No. App.config is what it says it is: application configuration info. That's what the designer uses and that's what the compiler generates your settings class from.
When you save user settings, the actual values get written out to:
C:\<username>\AppData\Local\<company name>\<app.exe>_url_<hash>\<version>\user.config
Go look there
|
|
|
|
|
Hi,
Below is the declaration at class level.
<pre lang="c#">int[] PossibleValues = new int[6];
int[][] JaggedArray = new int[50][];
int JaggedVar = 0;</pre>
Then in a function, I am assigning PossibleValues array to Jaggedarray like this.
[PossibleNumbers is a function that returns an array of possible numbers for a cell in a grid.]
<pre lang="c#">PossibleValues = PossibleNumbers();
JaggedArray[jaggedVar] = PossibleValues;
jaggedVar++;</pre>
The number of elements in PossibleValues in each iteration may vary,but it will never exceed 6.I dont want Jaggedarray to store zeros of PossibleValues so I changed the code to:
<pre lang="c#">PossibleValues = PossibleNumbers();
for (int i = 0; i < PossibleValues.Length; i++)
{
if (PossibleValues[i] != 0)
{
JaggedArray[jaggedVar][i] = new PossibleValues[i];
}
}
jaggedVar++;</pre>
But this gives null reference exception at
JaggedArray[jaggedVar][i] = new PossibleValues[i];
I searched it over the internet and came to know that JaggedArray remains null hence values cannot be assigned this way.How to resolve this?
Any help would be appreciated.
Thanks in advance!
|
|
|
|
|
There seems to be some inconsistencies in your code (and the formatting needs to be fixed). I cannot get the above to compile cleanly as your variable names are not all correct: you have JaggedVar defined at the top. but use jaggedVar (case change) later. You are also incrementing jaggedVar outside your for loop.
Also the statement
JaggedArray[jaggedVar][i] = new PossibleValues[i];
does not make sense.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
I'm not sure if I understood everything correctly, but if you don't want PossibleValues to contain a number 0. I think you should change the method "PossibleNumbers" to return an array that does not contain a 0.
I also think 'new PossibleValues[i]' is wrong. PossibleValues[i] has a value you cannot re-instantiate it.
Probably you need something like (pseudocode):
if value = 0
CreateNewRandom int between 1 and x
PossibleValues[i] = randomint
JaggedArray[jaggedVar][i] = PossibleValues[i]
hope this helps.
V.
|
|
|
|
|
Thanks for your reply.
I m implementing Sudoku that computer will play after the user inputs certain numbers in its grid. The logic that I m following is that the function PossibleNumbers() calculates the numbers that are possible for each cell of 9x9 grid of Sudoku.The number of numbers possible for each cell may Vary. If for example 1, 3 are numbers possible for one cell, then 2,3,4 maybe possible for other cell.PossibleNumbers() runs for every cell of the grid. Here is its implementation
private int[] PossibleNumbers()
{ int[] PossibleNumbers = new int[] { 1, 2, 3, 4, 5, 6 };
Array.Clear(PossibleValues, 0, 6);
int k = 0;
for (int i=0 ; i < PossibleNumbers.Length; i++)
{
int count = 0;
for (int j=0 ; j < tempArray.Length; j++)
{
if (tempArray[j] == Convert.ToInt32(PossibleNumbers[i]))
{
count++;
break;
}
}
if (count == 0)
{
PossibleValues[k] = PossibleNumbers[i];
k++;
}
}
return PossibleValues;
}
The size of PossibleValues is set to 6 at the time of initializing it.so if two numbers are possible for a cell then the remaining 4 indexes will contain zero. And this is the problem. How do I go about it.
Please Help!
Thanks
|
|
|
|
|
This is the implementation. The inconsistency in variable declaration and usage was a typo. How do I proceed now ?
PossibleValues = PossibleNumbers();
for (int i = 0; i < PossibleValues.Length; i++)
{
if (PossibleValues[i] != 0)
{ JaggedArray[jaggedVar][i] = PossibleValues[i];
}
}
jaggedVar++;
|
|
|
|
|
ariez88 wrote: How do I proceed now ?
With what?
V.
|
|
|
|
|
With assigning PossibleValues to Jaggedarray without encountering Null Reference Exception.
|
|
|
|
|
If it is for a Sudoku I'm not sure from your code, how you'll implement it.
However I would use the following logic.
Create a 9x9 integer array which will be your playboard.
After that you'll need to create a "solved" sudoku (I think there is only one solution, not sure)
Somewhere on the internet you should be able to find how many digits you need where to be able to solve the soduku. Create a copy of the solution, remove the digits that are not necessary and voila, your sudoku is ready.
There is, in my opinion, no need for a jagged array.
Hope this helps.
V.
|
|
|
|
|
Actually, the user will input the numbers that are normally given in any Sudoku game,
once those numbers are entered, the computer will present the solution using If-Else logic throughout the game, calculating the possible numbers for each cell of the 9x9 grid.
|
|
|
|
|
That doesn't seem like a bad solution, but still no need for jagged array's, you need to use a fixed multidimensional array of 9x9.
V.
|
|
|
|
|
Hi All !
I have a pdf file, place in the debug directory (in any drive) . I want to open this file with any full path :
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
Process.Start(appPath + "\\Debug\\HelpFile.pdf");
But I have an error that can not file file ,
pl z help me !
thanks in advance !
|
|
|
|
|
Message Removed
modified 8-May-12 16:18pm.
|
|
|
|
|
@"..\Debug\HelpFile.pdf");
It's works !
Thanks in advance!
Regards !
|
|
|
|
|
Yeah, but when you deploy the application in production, it'll fail! Unless you have the Debug folder created when you install the application, BOOM!
|
|
|
|
|
|
thanx !
|
|
|
|