Showing posts with label downloaded. Show all posts
Showing posts with label downloaded. Show all posts

Friday, March 30, 2012

Problems installing MSDE

Hi

I've recently downloaded and installed MSDE. I used the instructions from the Microsoft website that makes it as an instance of VSDOTNET. When I rebooted after installing it, there was absolutely no service for the SQL Server Service Manager to do anything with - the icon was in my tray with a blank circle, not a green Play or a red Stop symbol. So I uninstalled it, with an aim to reinstalling it as I had done before - without specifying an instance name.

Only trouble is, I'm now trying to reinstall it using:

setup SAPWD=<pword> SecurityMode=SQL

and I'm getting an error message that says "Setup failed to configure the server. Refer to the serveer error logs and setup error logs for more information." when the progress bar is about 2-thirds of the way along. It does this when I try to install as an instance of VSDOTNET again. It just won't play, and I don't know how to get at the logs to see what's up.

I'm running Win2K SP3, with .NET 1.1. Anyone able to help me?

Thanks
JonCheck to see if you are installing SP3a. If so include the DISABLENETPROTOCOLS=0 in the setup command line. This will ensure that you have enabled the network protocols for a new install. You also don't have to create an instance at installation time.sql

Wednesday, March 28, 2012

Problems In Connecting Using New Driver

I tried using the new MSSQL 2005 driver which I downloaded from
http://blogs.msdn.com/dataaccess/ar...28/475032.aspx.
But I had problems in connecting to the database using it.
I used the following lines to make the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con1 =
DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=BCTEST"
,
"fiorano", "fiorano123");
I got the following error.
com.microsoft.sqlserver.jdbc.SQLServerException: Failed
Logon:com.microsoft.sqls
erver.jdbc.SQLServerException: DBComms.error reading input. Context:Read
packet
header, Unexpected end of stream, readBytes:-1, negative read result,
PktNumber:
0, ReadThisPacket:0, PktDataSize:4,096
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown
Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JDBCTestYukon.main(JDBCTestYukon.java:17)
I even tried with the simpler URL "jdbc:sqlserver://localhost" but I got the
same error.
Please help.If I use Type1 driver like below its working fine.
java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection1 =
java.sql.DriverManager.getConnection("jdbc:odbc:DEV329;user=sa;password=ontr
ack20");
But for the thin driver getteing the same exception..I need to upgrade
my Java version'

Monday, March 26, 2012

Problems grasping ado.net - coming from asp background

Hi, i've downloaded a membership and roles provider but i am very new to ado.net. I have come fromasp background. Here's mycode:

public override void AddUsersToRoles(string[] usernames, string[] rolenames) {
// Validate arguments
foreach (string rolename in rolenames) if (!this.RoleExists(rolename)) throw new ProviderException("Role name not found");
foreach (string username in usernames) {
if (username.IndexOf(',') > 0) throw new ArgumentException("User names cannot contain commas.");
foreach (string rolename in rolenames) {
if (IsUserInRole(username, rolename)) throw new ProviderException("User is already in role.");
}
}

SqlConnection db = this.OpenDatabase();
SqlCommand cmd = new SqlCommand("INSERT INTO UsersInRoles (UserName, RoleName) VALUES (@.UserName, @.RoleName)", db);
cmd.Parameters.Add("@.UserName", SqlDbType.VarChar, 100);
cmd.Parameters.Add("@.RoleName", SqlDbType.VarChar, 100);
SqlTransaction tran = null;

try {
tran = db.BeginTransaction();
cmd.Transaction = tran;
foreach (string username in usernames) {
foreach (string rolename in rolenames) {
cmd.Parameters["@.UserName"].Value = username;
cmd.Parameters["@.RoleName"].Value = rolename;
cmd.ExecuteNonQuery();
}
}
tran.Commit();
}
catch {
tran.Rollback();
throw;
}
finally {
db.Close();
}
}

private SqlConnection OpenDatabase() {
SqlConnection DB = new SqlConnection(this.connectionString);
DB.Open();
return DB;
}

The problem i have is that the table structure they provide is to have:

UsersInRoles
- UserName (foreign key to users table)
- RoleName (foreign key to roles table)

but the table structure i have is:

UsersInRoles
- UserID (foreign key to users table)
- RoleID (foreign key to roles table)

So what i need to do is lookup the UserID and RoleID from the appropriate tables based on the UserName and RoleName before doing the insert. However i am not familiar with the new syntax. I'm sure i could bodge something together but i assume this new syntax is something to do with running all the insert statements in one (transaction) so it doesn't have to keep taking round trips back to sqlserver.

Appreciate if someone could show me how this could be done. Thanks

If I understand you correctly, this issue does not differ from ASP to ASP.NET. You need to get UserName(RoleName) based on UserID(RoleID) and then insert the values into UsersInRoles table, right? If so, you can create a stored procedure like this:

CREATE PROCEDURE sp_InsUsersInRoles @.RoleID INT
AS
INSERT INTO UsersInRoles (UserName, RoleName)
SELECT UserName, RoleName
FROM Users join Roles ON Users.RoleID=Roles.RoleID
WHERERoles.RoleID=@.RoleID

Then you can easily call the stored procedure, just remember to set the SqlCommand.CommandType to StoredProcedure, and add parameter for it.

|||

Change:

SqlCommand cmd = new SqlCommand("INSERT INTO UsersInRoles (UserName, RoleName) VALUES (@.UserName, @.RoleName)", db);

to:

SqlCommand cmd = new SqlCommand("INSERT INTO UsersInRoles (UserID, RoleID)SELECT (SELECT UserIDFROM UsersWHERE Username=@.UserName),RoleIDFROM RolesWHERE RoleName=@.RoleName", db);
|||

Hi Motley worked a treat. However i also tried doing:

SqlConnection db = this.OpenDatabase();
SqlCommand cmd = new SqlCommand("INSERT INTO UserRoles (UserName, RoleName) VALUES (@.UserId, @.RoleId)", db);
cmd.Parameters.Add("@.UserId", SqlDbType.Int);
cmd.Parameters.Add("@.RoleId", SqlDbType.Int);
SqlTransaction tran = null;

try {
tran = db.BeginTransaction();
cmd.Transaction = tran;
foreach (string userName in userNames) {
SqlCommand cmd2 = new SqlCommand("SELECT UserId FROM Users WHERE UserName = @.UserName", db);
cmd2.Parameters.Add("@.UserName", SqlDbType.VarChar, 100).Value = userName;
int userId = (int)cmd2.ExecuteScalar();

foreach (string roleName in roleNames) {
SqlCommand cmd3 = new SqlCommand("SELECT RoleId FROM Roles WHERE RoleName = @.RoleName", db);
cmd3.Parameters.Add("@.RoleName", SqlDbType.VarChar, 100).Value = roleName;
int roleId = (int)cmd3.ExecuteScalar();

cmd.Parameters["@.UserId"].Value = userId;
cmd.Parameters["@.RoleId"].Value = roleId;
cmd.ExecuteNonQuery();
}
}
tran.Commit();
}
catch {
tran.Rollback();
throw;
}
finally {
db.Close();
}

but it didn't work.

Any ideas what i did wrong. Cheers

|||

Is RoleName unique within Roles? If you are using the default asp.net membership database structure, then it is not. RoleName is only unique within an Application, and hence may appear in Roles multiple times for different applications. If you have multiple application support, then you will need to supply the application name or application id to your roleid lookup.

My code in this case will add the user to the RoleName of all applications in which the role appears. The same problem is true for UserName as well if you are using multiple applications, but my code will fail in that case as well.

Otherwise I see nothing wrong with your code.

|||

On the other hand, it could be transaction related. I don't normally use the transaction support in ASP.NET. I prefer to use SQL transactions for all my work since I tend to create large batches within my SQL, and wrap that rather than wrapping many SqlCommands. In any case, you might try adding the cmd2 and cmd3 to the transaction as well.

It would also help if you posted what error you are getting rather than just "It didn't work".

|||

Hi, i can't see how to track the error, i'm using visual studio web developer edition. I tried using the built in asp.net config tool to manage my users but when i put a break point in my code it does nothing. However to test if it was reaching this part of the code i did a dummy insert statement and it worked.

I also tried putting an exception on the catch part and doing console.writeline(ex.Message) but that didn't do anything either.

Appreciate your help once more. Thanks

Saturday, February 25, 2012

Problem with valid owner

I have just downloaded the MS SQL Server Management Studio Express, and are following a tutorial on www.learnvisualstudio.net

Now I am having trouble with some owner information. The message says :

"Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTORIZATION statement to set the database owner to a valid login, then add the database diagram support objects"

I should mention that my WIN XP username is "Bj?rn" with the Norwegian letter "?" in the middle. I suspect it to have a problem with that letter?

Any better suggestions?

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=120849&SiteID=1

When the database does not have a valid owner, the database dialog displays the owner as the logged in user. (This issue will be fixed in SP1.)

The "no valid owner" issue usually comes up when databases are owned by SQL-authentication logins and are upgraded, detached/attached to another server, or restored from backup to another server. The SID (a large number) doesn't match any existing login on the new server, so the owner name remains whatever it was on the old server, but it is marked invalid. Explicitly setting the owner to a valid principal on the server solves the problem.

There is also a known issue when the UI tries to install the database support objects on databases where the compatibility level is set to 80 (SQL Server 2000). The installation fails and the UI incorrectly reports that the database has no valid owner. Setting compatibility level to 90 (SQL Server 2005) before installing the diagram support objects solves this problem. (This issue will also be fixed in SP1.)


HTH

|||

Thank you for taking the time to help me.

The compatibility level was already set to 90, so that didn't solve the problem.

When I tried to set a new owner, I got this message:

TITLE: Microsoft SQL Server Management Studio Express

Set owner failed for Database 'MyCompany'. (Microsoft.SqlServer.Express.Smo


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

An entity of type database cannot be owned by a role, a group, an approle, or by principals mapped to certificates or asymmetric keys. (Microsoft SQL Server, Error: 15353)

|||

Hi,

Do you fin a solution ? I have the same problem ...

Thanks

|||Yes. I think I changed the owner to sa (server admin I think it is)

Problem with valid owner

I have just downloaded the MS SQL Server Management Studio Express, and are following a tutorial on www.learnvisualstudio.net

Now I am having trouble with some owner information. The message says :

"Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTORIZATION statement to set the database owner to a valid login, then add the database diagram support objects"

I should mention that my WIN XP username is "Bj?rn" with the Norwegian letter "?" in the middle. I suspect it to have a problem with that letter?

Any better suggestions?

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=120849&SiteID=1

When the database does not have a valid owner, the database dialog displays the owner as the logged in user. (This issue will be fixed in SP1.)

The "no valid owner" issue usually comes up when databases are owned by SQL-authentication logins and are upgraded, detached/attached to another server, or restored from backup to another server. The SID (a large number) doesn't match any existing login on the new server, so the owner name remains whatever it was on the old server, but it is marked invalid. Explicitly setting the owner to a valid principal on the server solves the problem.

There is also a known issue when the UI tries to install the database support objects on databases where the compatibility level is set to 80 (SQL Server 2000). The installation fails and the UI incorrectly reports that the database has no valid owner. Setting compatibility level to 90 (SQL Server 2005) before installing the diagram support objects solves this problem. (This issue will also be fixed in SP1.)


HTH

|||

Thank you for taking the time to help me.

The compatibility level was already set to 90, so that didn't solve the problem.

When I tried to set a new owner, I got this message:

TITLE: Microsoft SQL Server Management Studio Express

Set owner failed for Database 'MyCompany'. (Microsoft.SqlServer.Express.Smo


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

An entity of type database cannot be owned by a role, a group, an approle, or by principals mapped to certificates or asymmetric keys. (Microsoft SQL Server, Error: 15353)

|||

Hi,

Do you fin a solution ? I have the same problem ...

Thanks

|||Yes. I think I changed the owner to sa (server admin I think it is)