Showing posts with label program. Show all posts
Showing posts with label program. Show all posts

Tuesday, March 27, 2012

Attach db from installer (only read mode)

Hi,

I have made setup of my program,

I need to attach a db to the server. To do this:

- Copy mdf and ldf files into default data folder of instance of sqlexpress

- run scrip from custom action in the installer that:

a. attach the db

b. create login

c. create user for login in db

There is a problem...I run script slq file by sqlcmd and launch it from a c# process.

The rusult is that the db was attacched but in only read mode, and the point c not work.

If I execute manually the same script sql with sqlcmd in dos window, it work without problem in all point: a,b and c

What are the reason of this?

I think that start process in c# not work correctly....this is the code:

process = new Process();

process.StartInfo.FileName = "sqlcmd.exe";

process.StartInfo.Arguments = commandLine;

process.Start();

process.WaitForExit();

help me, plese!

thanks in advance

andrea

SInce you have posted this in Express forum, i strongly feel that you should use SQL Server Express User Instance feature. Its nothing but Embedded Database.

Refer this.

http://blogs.msdn.com/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-instances-in-management-studio.aspx

Madhu

Thursday, March 22, 2012

Asynchronous ADO Command execute

I am getting a "Program Error" when I try to run a stored procedure. It says it generates an error log but I don't find it in Windows 2000.
Has anyone seen anything like this?
Please help,
ThanksIt also happens inconsistently. Sometimes, it just runs fine and sometimes, it just gives a Program Error and everything blows out.|||Originally posted by archnam
I am getting a "Program Error" when I try to run a stored procedure. It says it generates an error log but I don't find it in Windows 2000.
Has anyone seen anything like this?
Please help,

Thanks

Have you looked in the SQL Server error log in enterprise manager?|||Where exactly are error logs in the SQL Server under Enterprise Manager?
Also, if I put a breakpoint in my program, it seems to run fine and when I just run it, it bombs, do you think may be I should put some delay in it. The Command.Execute might be taking some time to run.

Sunday, February 19, 2012

ASPNET account permissions

I am new to Reporting Services and still learning, but it is a very nice exciting program. I built a new Report and was experimenting with Grouping in reports and using the parameters. Now I would like to Deploy the report to the Report Server so I can use this report on our intranet, however I get the error that the ASPNET account does not have the proper permissions. I am sure that I need to set up ASPNET to have "write" abilities.

What folder(s) do I need to make sure that ASPNET has this? Or should I be looking elsewhere to set up the ASPNET account on the Report Server?

Thanks for the information.

Will you post the exact error message you are seeing? Does it indicate which resource is not permissioned?|||

This is the exact error message when I try to deploy the report:

Error 1 The permissions granted to user 'BRAD\ASPNET' are insufficient for performing this operation. 0 0

|||The folder that needs permission is the root folder in the report server namespace. But running as the ASPNet account is usually not what you want, since all users will be connecting as the same user account. It looks like your report server config file has impersonation turned off. Is this something you changed intentionally?|||

Brian,

For now I did go into Report Services through the SQL Management Studios, went into properties and did see that ASPNET was unchecked. I checked it and now the reports deploy just fine.

Thanks for the great information.

Thursday, February 16, 2012

ASP.NET,Gettting Error in the Program

Hi,

please have look into the code and let me know the solution plz.

string

ProID;try

{

using(SqlConnection conn=new SqlConnection(source))

{

conn.Open();

DataSet ds=

new DataSet();

DDLProject.Items.Clear();

SqlCommand cmd=

new SqlCommand("SP_ProjectSelect",conn);

cmd.CommandType=CommandType.StoredProcedure;

cmd.Parameters.Add("Name",SqlDbType.NChar,30,"@.Name");

cmd.UpdatedRowSource=UpdateRowSource.None;

cmd.Parameters["Name"].Value=DDLProductLine.SelectedItem;

SqlDataReader dr=cmd.ExecuteReader(); ---->>>> Here iam getting Following Error.

while(dr.Read())

{ Response.Write(dr["ID"].ToString());

}

}

}

catch(System.Exception ex)

{

Response.Write(ex);

}

Error:

System.InvalidCastException: Object must implement IConvertible. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader() at MIS.UI.ResourceList.DDLProductLine_SelectedIndexChanged(Object sender, EventArgs e) in c:\inetpub\wwwroot\dotnet pgms\mis\ui\resourcelist.aspx.cs:line 121

Any suggestion plzz,where went wrong.

Thanks in advance

Regards

Mahesh Reddy

Is it possible your stored procedure "SP_ProjectSelect" is not returning a result set? That's what it sounds like.|||

I think your oder in parameter.add was not correct.

The order should be SQL parameter, DataType, and Input Value.

In your case, it looks like

cmd.Parameters.Add("@.Name",SqlDbType.NChar,30,Name);

Here, "@.Name" is SQL parameter name, Name is the valueable you want to input. You can use "Name" for test. In this case, you will insert "Name" into table.

Also, NChar is not the good datatype for string name. I suggest you change it to VarChar (You need change it in SQL SP too).

Hope it helps

ASP.Net with SQL-DMO

Any help is appreciated!

I try to convert a VB 6 program to ASP.Net.

The original vb 6 program uses SQL-DMO to gather information from SQL Servers using 'Microsoft SQLDMO Object Library':

vb6:
Referenced te DMO inside VB 6
Dim oSQLSvr2 As New SQLServer2

ASP.Net:

I got Compiler Error Message: BC30002: Type 'SQLServer2' is not defined.

ASP.Net source code:

<%@. Page Language="VB" Debug="TRUE" %>
<%@. Import namespace="System.Data" %>
<%@.Import namespace="System.Data.OLeDb"%>
<%@.Import namespace=""sqldmo"%>
<%@.Import namespace=""sqldmo.SQLServer2"%
<script runat="Server">
Sub btn_Click(S As Object, e As EventArgs)
Dim oSQLSvr2 as New SQLServer2

oSQLSvr2.LoginTimeout = 30
oSQLSvr2.LoginSecure = True
oSQLSvr2.Connect "ORGDEV03"
End Sub
</Script
<html>
<head><title>test
</title></head>
<body>
<form runat="Server">
Title
<p/>
<asp:Button Text="Connect to SQL Server" OnClick="btn_Click" Runat="Server"/
</form>
</body
</html>There is no namespace called sqldmo.SQLServer2, so you should remove that @.Import namespace line.

Instead of this:

Dim oSQLSvr2 as New SQLServer2
use this
Dim oSQLSvr2 AS New SQLDMO.SQLServer2

Terri|||It is still doesn't work. Any help?|||I tried the exact code following and it works fine on my machine (one thing I did notice with your code is that you can an extra double quote in your Import namespace="sqldmo" directive):


<%@. Page Language="VB" Debug="TRUE" %>
<%@. Import namespace="System.Data" %>
<%@. Import namespace="System.Data.OLeDb"%>
<%@. Import namespace="sqldmo"%
<script runat="Server">
Sub btn_Click(S As Object, e As EventArgs)
Dim oSQLSvr2 as New SQLDMO.SQLServer2

oSQLSvr2.LoginTimeout = 30
oSQLSvr2.LoginSecure = True
oSQLSvr2.Connect("(local)")
End Sub
</Script
<html>
<head><title>test
</title></head>
<body>
<form runat="Server" ID="Form1">
Title
<p/>
<asp:Button Text="Connect to SQL Server" OnClick="btn_Click" Runat="Server" ID="Button1" NAME="Button1"/
</form>
</body
</html>

Terri|||Terri,

I am not using VS.Net Environment to create the ASP.net Page. That's why mine doesn't work.

The sqldmo.dll (referenced in my code) is a COM object(not .Net Assembly) so that the namespace is not imported in my code.

To resolve this problem, I copy and paste my code in VS.Net and compile it. Then copy the \bin\Interop.sqldmol.dll to my ASP.Net application root directory. It works fine.

Thank again.

Pak