Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Friday, March 30, 2012

how to controll user access in comercial deployment?

Hello,
We have used SSAS and SSRS to develop a BI reporting suite for our data
warehouse and would like to deploy this into our customer base, but at the
same time protect our investment.
How do we control or limit the number of users that can use our cubes and
reports? We would like to control user numbers by a licence arrangement -
either concurrent or named - but fear once a user has our developments
installed they only need to increase their MS licences and away they go...
Any help and advice appreciated.
StephenYou could do the following for named users.
1. Have your own routine that authorizes. Put the user names into a table.
Then somewhere else have the total number allowed encrypted.
2. In your reports (or even better in stored procedures) use the User!UserID
global parameter and verify the user. You could do this in a custom assembly
too. You could put a nag message on each report.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Stephen Lonsdale" <StephenLonsdale@.discussions.microsoft.com> wrote in
message news:4AE7D682-F6D1-4E60-8641-03EC900EA69D@.microsoft.com...
> Hello,
> We have used SSAS and SSRS to develop a BI reporting suite for our data
> warehouse and would like to deploy this into our customer base, but at the
> same time protect our investment.
> How do we control or limit the number of users that can use our cubes and
> reports? We would like to control user numbers by a licence arrangement -
> either concurrent or named - but fear once a user has our developments
> installed they only need to increase their MS licences and away they go...
> Any help and advice appreciated.
> Stephen

How to Control Print Button in SP2 ?

I want control print button for user to use print button one time per one
user account
How i do ?
Thank youHi,
You can control the print button with the report viewer style sheet
"htmlviewer.css".
Change the style
.ToolbarPrint
{
display: inline;
}
to
.ToolbarPrint
{
display: none;
}
Make sure u take a backup of the existing css and give a new name like
"noprint.css".
So have a logic in your system where you have a printer counter in the user
session, and if the counter is > 1, pass the following parameter to the
report URL
"rc:StyleSheet=noprint"
eg:
<report url >&rc:StyleSheet=noprint
This will hide the print button from the viewer.
Hope this will give a workaround to solve the problem.
rgds,
Kolitha
dkolitha@.gmail.com
www.dkolitha.com
"Zong" wrote:
> I want control print button for user to use print button one time per one
> user account
> How i do ?
>
> Thank you
>
>

how to control a column limited to display?

Hi,

Can I control a column to displayed to a specifal user or specifal role?

If not the specifal user or specifal role, the column will can not be displayed.

Thank you.

Jeffers

You can set a conditional column visibility using User!UserID. For more involved scenarios, you may need to whip out some code to find the role/group the user belongs to given the user logon name.

Wednesday, March 28, 2012

how to connect to sql server as other's window login rather than user's window login thorugh A

Dear members,

In MSDN, it says that it is recommended to use windows authentication to connect to SQL Server rather than use mixed authentication.

I create user delta\sqluser on windows OS, and I specify in my webform ASP.NET script below :

protected System.Web.UI.WebControls.Label Label1;
private string _connString = @."data source=delta\sql2000;initial catalog=northwind;integrated security=false;user id=delta\sqluser";
/*
comment : I login to my windows as delta\koronx, and I want to every user (including me), connected to sql server through IIS, will be identified as delta\sqluser not as user's login (impersonate)
*/
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection(_connString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select suser_sname()";

conn.Open();


string userName = cmd.ExecuteScalar() as string;
conn.Close();
conn.Close();
Label1.Text = userName;
}

at web.config, I add :
<identity impersonate="false" userName="delta\sqluser" password="" />

at IIS webApplication1's properties, tab "Directory Security", at "Authentication and access control" section, I checked "enable anonymous access" with user : DELTA\IUSR_DELTA and checked "Integrated Windows Authentication",

at query analyzer, I login as "sa" and execute script below :
exec sp_grantdbaccess 'delta\sqluser','northwind'

when I run the ASP.NET script, error at conn.Open(); with error message :
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

What should I do so that IIS login to SQL Server as user delta\sqluser not as "NT AUTHORITY\NETWORK SERVICE" ?

Regards,

Koronx

Your connection string is incorrect. You specify using SQL Authentication (integrated security = false) but what you want is integrated security. However, the connection string for integrated security does not allow you to impersonate a user. You should look for help on configuring your application to impersonate a specific account on an ASP.NET forum at: http://forums.asp.net/.

Thanks
Laurentiu

how to connect to sql server as other's window login rather than user's window login thoru

Dear members,

In MSDN, it says that it is recommended to use windows authentication to connect to SQL Server rather than use mixed authentication.

I create user delta\sqluser on windows OS, and I specify in my webform ASP.NET script below :

protected System.Web.UI.WebControls.Label Label1;
private string _connString = @."data source=delta\sql2000;initial catalog=northwind;integrated security=false;user id=delta\sqluser";
/*
comment : I login to my windows as delta\koronx, and I want to every user (including me), connected to sql server through IIS, will be identified as delta\sqluser not as user's login (impersonate)
*/
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection(_connString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select suser_sname()";

conn.Open();


string userName = cmd.ExecuteScalar() as string;
conn.Close();
conn.Close();
Label1.Text = userName;
}

at web.config, I add :
<identity impersonate="false" userName="delta\sqluser" password="" />

at IIS webApplication1's properties, tab "Directory Security", at "Authentication and access control" section, I checked "enable anonymous access" with user : DELTA\IUSR_DELTA and checked "Integrated Windows Authentication",

at query analyzer, I login as "sa" and execute script below :
exec sp_grantdbaccess 'delta\sqluser','northwind'

when I run the ASP.NET script, error at conn.Open(); with error message :
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

What should I do so that IIS login to SQL Server as user delta\sqluser not as "NT AUTHORITY\NETWORK SERVICE" ?

Regards,

Koronx

Your connection string is incorrect. You specify using SQL Authentication (integrated security = false) but what you want is integrated security. However, the connection string for integrated security does not allow you to impersonate a user. You should look for help on configuring your application to impersonate a specific account on an ASP.NET forum at: http://forums.asp.net/.

Thanks
Laurentiu

Monday, March 26, 2012

How to connect to ODBC data source through C#. net

Hi experts,
I am doing an application which takes the DSN name from user in text
box and then open the ODBC data source dialog box. i.e. I want the
(ODBC data source administrator) form which comes after clicking on
ODBC data source icon in administrative tools.
Now my problem is that is it possible to call that system form
(utility) through my program or I have to design the same form (ODBC
data source administrator).
If I can call that form then please tell me how....i can do that?
Any help will be appreciated.
Thanks
DineshYou would be better off posting this in a C# newsgroup. This is for
Reporting Services.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Dinesh" <dinesht15@.gmail.com> wrote in message
news:1166091132.509799.4510@.f1g2000cwa.googlegroups.com...
> Hi experts,
> I am doing an application which takes the DSN name from user in text
> box and then open the ODBC data source dialog box. i.e. I want the
> (ODBC data source administrator) form which comes after clicking on
> ODBC data source icon in administrative tools.
> Now my problem is that is it possible to call that system form
> (utility) through my program or I have to design the same form (ODBC
> data source administrator).
> If I can call that form then please tell me how....i can do that?
> Any help will be appreciated.
> Thanks
> Dinesh
>

How to connect to DB with username and passwd?

Hi I've created a login in my SQL Server 2005 like this:

CREATE LOGIN testuser
WITH PASSWORD = 'TestPWD';
USE DB1;
CREATE USER testuser FOR LOGIN testuser;
GO

now i want to connect from a c# app with the following connection STring
"Data Source=TURM21;Initial Catalog= Db1; Database= Db1 ; USER = testuser; PASSWORD = TestPWD; pooling=false; "

and i get the following Exception:
SqlConnection Handle : System.Data.SqlClient.SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

CAn somebody help me? Whats wrong? Is it my connection string?

GreetzYou should use GRANT statement to grant to this user privillege use the DB1 before use that username to login to DB|||have granted access to user manually in DB.

Changed the Conn String an d now it works:

"Data Source=TURM21; Database= Db1 ; USER id= testuser; PASSWORD = testPWD; Trusted_Connection=True ";

Set the Trusted_Connection to true

how to connect to a local sql server on your laptop?

i have problems connecting to the local server on my laptop. i ahve used the following code but it gives me an error saying login flaied for user "sa" or "sekhar".

i tried using the username and password i use to log onto my computer. but it doesnt work.
can anyone tell me how to do it?

the code is typed is

connection = new sqlconnection("server=localhost;uid=sekhar;pwd=sekhar;database=chandu")
..................
.............................
........................
connection.open()..............i have all the next statements correct.
my username is sekhar and the password is sekhar too but it gives me an error.
somebody help me

Thank you

sekhartry using server=(local)

and whether you need the password or not depends on how the SQL Server is set up. does the users view show a user called 'sekhar'? no? when you right click the server node and go to properties->security, does it show windows auth only, or Windows and SQL Server auth?

Friday, March 23, 2012

How to connect the remote SQL 2005 using different user name?

Hi,
I am using the SQL 2005 management studio and trying to connect a remote SQL
2005 standard edition server in the mix authentication mode. I need to pick
up a different windows user name which existing in remote Server but is not
the one I am using to login my local. By default, the connection pick up the
user name and password which is using for local login and gray out, it
doesn’t allow to make any changes, does anyone have the idea how to make the
change?
Thanks
Wendy
One thing to try is to create a windows account and password
that is exactly the same (password, user name) and add it to
whatever PC, server you are connecting from. Then try
logging in with that login or do a Run As to run SSMS and
run as the windows account that matches the remote server
account.
-Sue
On Mon, 13 Mar 2006 13:13:28 -0800, Wendy
<Wendy@.discussions.microsoft.com> wrote:

>Hi,
>I am using the SQL 2005 management studio and trying to connect a remote SQL
>2005 standard edition server in the mix authentication mode. I need to pick
>up a different windows user name which existing in remote Server but is not
>the one I am using to login my local. By default, the connection pick up the
>user name and password which is using for local login and gray out, it
>doesnt allow to make any changes, does anyone have the idea how to make the
>change?
>Thanks
>Wendy
|||Hi Sue,
Thanks for your replay.
I manage all multiple SQL servers from one remote management studio, looks
like the only way works is using SQL authentication. That means the windows
authentication is very limited.
Wendy
"Sue Hoegemeier" wrote:

> One thing to try is to create a windows account and password
> that is exactly the same (password, user name) and add it to
> whatever PC, server you are connecting from. Then try
> logging in with that login or do a Run As to run SSMS and
> run as the windows account that matches the remote server
> account.
> -Sue
> On Mon, 13 Mar 2006 13:13:28 -0800, Wendy
> <Wendy@.discussions.microsoft.com> wrote:
>
>
sql

How to connect the remote SQL 2005 using different user name?

Hi,
I am using the SQL 2005 management studio and trying to connect a remote SQL
2005 standard edition server in the mix authentication mode. I need to pick
up a different windows user name which existing in remote Server but is not
the one I am using to login my local. By default, the connection pick up the
user name and password which is using for local login and gray out, it
doesn’t allow to make any changes, does anyone have the idea how to make t
he
change?
Thanks
WendyOne thing to try is to create a windows account and password
that is exactly the same (password, user name) and add it to
whatever PC, server you are connecting from. Then try
logging in with that login or do a Run As to run SSMS and
run as the windows account that matches the remote server
account.
-Sue
On Mon, 13 Mar 2006 13:13:28 -0800, Wendy
<Wendy@.discussions.microsoft.com> wrote:

>Hi,
>I am using the SQL 2005 management studio and trying to connect a remote SQ
L
>2005 standard edition server in the mix authentication mode. I need to pick
>up a different windows user name which existing in remote Server but is not
>the one I am using to login my local. By default, the connection pick up th
e
>user name and password which is using for local login and gray out, it
>doesnt allow to make any changes, does anyone have the idea how to make th
e
>change?
>Thanks
>Wendy|||Hi Sue,
Thanks for your replay.
I manage all multiple SQL servers from one remote management studio, looks
like the only way works is using SQL authentication. That means the windows
authentication is very limited.
Wendy
"Sue Hoegemeier" wrote:

> One thing to try is to create a windows account and password
> that is exactly the same (password, user name) and add it to
> whatever PC, server you are connecting from. Then try
> logging in with that login or do a Run As to run SSMS and
> run as the windows account that matches the remote server
> account.
> -Sue
> On Mon, 13 Mar 2006 13:13:28 -0800, Wendy
> <Wendy@.discussions.microsoft.com> wrote:
>
>

How to connect the remote SQL 2005 using different user name?

Hi,
I am using the SQL 2005 management studio and trying to connect a remote SQL
2005 standard edition server in the mix authentication mode. I need to pick
up a different windows user name which existing in remote Server but is not
the one I am using to login my local. By default, the connection pick up the
user name and password which is using for local login and gray out, it
doesnâ't allow to make any changes, does anyone have the idea how to make the
change?
Thanks
WendyOne thing to try is to create a windows account and password
that is exactly the same (password, user name) and add it to
whatever PC, server you are connecting from. Then try
logging in with that login or do a Run As to run SSMS and
run as the windows account that matches the remote server
account.
-Sue
On Mon, 13 Mar 2006 13:13:28 -0800, Wendy
<Wendy@.discussions.microsoft.com> wrote:
>Hi,
>I am using the SQL 2005 management studio and trying to connect a remote SQL
>2005 standard edition server in the mix authentication mode. I need to pick
>up a different windows user name which existing in remote Server but is not
>the one I am using to login my local. By default, the connection pick up the
>user name and password which is using for local login and gray out, it
>doesn?t allow to make any changes, does anyone have the idea how to make the
>change?
>Thanks
>Wendy|||Hi Sue,
Thanks for your replay.
I manage all multiple SQL servers from one remote management studio, looks
like the only way works is using SQL authentication. That means the windows
authentication is very limited.
Wendy
"Sue Hoegemeier" wrote:
> One thing to try is to create a windows account and password
> that is exactly the same (password, user name) and add it to
> whatever PC, server you are connecting from. Then try
> logging in with that login or do a Run As to run SSMS and
> run as the windows account that matches the remote server
> account.
> -Sue
> On Mon, 13 Mar 2006 13:13:28 -0800, Wendy
> <Wendy@.discussions.microsoft.com> wrote:
> >Hi,
> >
> >I am using the SQL 2005 management studio and trying to connect a remote SQL
> >2005 standard edition server in the mix authentication mode. I need to pick
> >up a different windows user name which existing in remote Server but is not
> >the one I am using to login my local. By default, the connection pick up the
> >user name and password which is using for local login and gray out, it
> >doesnâ't allow to make any changes, does anyone have the idea how to make the
> >change?
> >
> >Thanks
> >
> >Wendy
>

How to Connect SQL server Using ASP.net

Dear ASP.NET user...

I'm a new user in ASP.NET...
i have a problem facing now...
I'm using SQL server as my database...
how do i CONNECT my web application using ASP.NET to SQL server??

What should i do?
any coding do i need to insert to my web HTML?

what i heard from my friend...she said web config can connect the web application to SQL server...?...it that work?

pls help me guys and gals...

From jhwong2610
URGENTVery often the web.config is used to store the connection string - that alone does not connect you to a database - using the connection string you have to open a sqlConnection and then proceed from there.

My best recommendation would be to pick up one of the ASP.NET books and look at one of the examples that uses data binding.|||Hi:
Like This


Dim Conn As New SqlConnection("ConnectionStringHere")
Dim Conn As New SqlCommand("Select * From Table", Conn)
Dim DRs As SqlDataReader
Conn.Open()
DRs = Comm.ExecuteReader()
If DRs.Read() Then
Response.Write(DRs("Column"))
End If
DRs.Close()
Conn.Close()
|||Add this to the web.config file:

<configuration>
<appSettings>
<add key="SQLConnStr" value="<your connection string" />
</appSettings
...

You can use the connectionstring in the code like this:

Dim str as connStr = System.Configuration.ConfigurationSettings.AppSettings("SQLConnStr")

How to connect Report in ReportViewer to a datasource?

Hi:

I am new to ReportViewer. I have an .aspx page that takes data that makes a request for a Permit. When the User clicks submit, I add the record to the database then get the unique identity of that record and display it in a popup (as a confirmation number). I would then like a report to show the data the User just submitted.

I have added an .aspx page called RequestReport.aspx and put a ReportViewer on it. I added a report called PermitRequest.rdlc with a textbox that acts as a Title. I linked RequestReport to pull PermitRequest.rdlc and it successfully displays the report. My question is that I don't know how to add a datasource to the report to show the new record. I did save the unique record id to a Session variable called "RequestID".

Please help with directions.

Thanks in advance!

a few questions:

1) Are you using textbox to display the report or some other contrl (like a table)

2) Do you want an SQL type solution that you can handle programatically or a solution where the report is tied to a fixed dataset.

3) What IDE are you using (Visual Web Express or Studio)

bullpit

|||

Hi:

(1) I am using a textbox to display the report name and a table to display the data.

(2) Either one is OK. I just want to be able to pass the newly given unique id to the report and then have the report display only the record data for that id. Each record will change with each user and each new entry.

(3) Visual Studio 2005 SP1 and framework 2.0 talking to a SQL Server 2000 database.

I now have the report displaying all records, but I only want to display the last saved record. Do I need to set a parameter to pass? If so, I see how to pass it programmatically with VB code behind. I don't see how I tell the report to accept a parameter as part of the SQL Statement.

|||

The way I do, I handle everything from codebehind...that gives me more control...that way i can send an SQL query to fetch whatever i want...in your case, you have the id...build a select query string in codebehind to select only the records with that id...then bind to the report...

these two funtions will help you get started if you want to go that way:

public void FindAll()
{
// Set the processing mode for the ReportViewer to Local
ReportViewer1.ProcessingMode = ProcessingMode.Local;
LocalReport rep = ReportViewer1.LocalReport;
rep.ReportPath = "Report.rdlc";
DataSet ds = GetSalesDataFull();
// Create a report data source for the sales order data
ReportDataSource dsMaintenanceDS = new ReportDataSource();
dsMaintenanceDS.Name = "DataSet1_Main";
dsMaintenanceDS.Value = ds.Tables["Main"];
rep.DataSources.Clear();

//example to set report parameter values from codebehind
ReportParameter param = new ReportParameter("nRows", dDownListNRows.SelectedValue);
this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { param });


rep.DataSources.Add(dsMaintenanceDS);
rep.Refresh();
}

private DataSet GetSalesDataFull()
{
DataSet ds = new DataSet();
string str = "";

str = @." WHERE ""ID""='" + <YOUR ID> ')";
string sqlSalesData = @."SELECT * FROM <TABLE NAME> " + str;

OdbcConnection connection = new OdbcConnection(<CONNECTION STRING>);
OdbcCommand command = new OdbcCommand(sqlSalesData, connection);
OdbcDataAdapter salesOrderAdapter = new OdbcDataAdapter(command);
salesOrderAdapter.Fill(ds, "Main");
salesOrderAdapter.Dispose();
command.Dispose();
return ds;
}

let me know if you have more questions.

good luck...bullpit

|||

The way I do, I handle everything from codebehind...that gives me more control...that way i can send an SQL query to fetch whatever i want...in your case, you have the id...build a select query string in codebehind to select only the records with that id...then bind to the report...

these two funtions will help you get started if you want to go that way:

public void FindAll()
{
// Set the processing mode for the ReportViewer to Local
ReportViewer1.ProcessingMode = ProcessingMode.Local;
LocalReport rep = ReportViewer1.LocalReport;
rep.ReportPath = "Report.rdlc";
DataSet ds = GetSalesDataFull();
// Create a report data source for the sales order data
ReportDataSource dsMaintenanceDS = new ReportDataSource();
dsMaintenanceDS.Name = "DataSet1_Main";
dsMaintenanceDS.Value = ds.Tables["Main"];
rep.DataSources.Clear();

//example to set report parameter values from codebehind
ReportParameter param = new ReportParameter("nRows", dDownListNRows.SelectedValue);
this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { param });


rep.DataSources.Add(dsMaintenanceDS);
rep.Refresh();
}

private DataSet GetSalesDataFull()
{
DataSet ds = new DataSet();
string str = "";

str = @." WHERE ""ID""='" + <YOUR ID> ')";
string sqlSalesData = @."SELECT * FROM <TABLE NAME> " + str;

OdbcConnection connection = new OdbcConnection(<CONNECTION STRING>);
OdbcCommand command = new OdbcCommand(sqlSalesData, connection);
OdbcDataAdapter salesOrderAdapter = new OdbcDataAdapter(command);
salesOrderAdapter.Fill(ds, "Main");
salesOrderAdapter.Dispose();
command.Dispose();
return ds;
}

let me know if you have more questions.

good luck...bullpit

|||

Hi Bullpit:

Thank you for your response. Do you have this in Visual Basic code behind? Also, if i do this all in the code behind...will I still have the fields in the dataset on the report to drag and drop to the table on the report? Will I still be able to layout the design of the report?

|||

Sorry, I do not have this code in VB. And yes, you will be able to design the table the way you want. I wanted my report to be dynamic, so I gave the user the choice to choose the fields she/he wants on the report..so whatever field name user chooses, corresponding values are bound to that column in details section...but if you don't want that, you can have the column names as static (by drag and drop)...i believe it should work...also, there are several tools online to convert c# to vb...you can use them...

P.S. If you choose to go codebehind, then remember to add the name of the datasource (in our case "DataSet1_Main") in the Report Data Source option in IDE.

good luck

Monday, March 19, 2012

how to configure multiple databases for one asp.net website

Hello:
I am working on a website that will require the use of multiple
databases - a unique database for each user in fact. It is somewhat of
a light CRM application and it is important to keep a user's customer
information in their own database.
So I am hoping to get input on the best way to implement this. The
approach I am using so far includes storing the database connection
string in a property of the user's profile object. However, this
requires referencing the profile object each time I hit the database.
And for pages that are using the sqldatasource control, that means
assigning the connectionstring property for that control in the
page_load event outside of an "if not page.ispostback" block. So I
wonder if there isn't a better way.
Any feedback would be really appreciated here.
ChrisHow about storing the user's database name in their profile object and/or in
a session variable. Then you can prefix all of your calls with the database
name:
... "EXEC " + session("database_name") + ".dbo.ProcedureName";
Of course, if you are doing this for scalability reasons, you will probably
want to consider multiple connection strings for different servers...
<chrishalldba@.yahoo.com> wrote in message
news:1138581470.361914.172540@.o13g2000cwo.googlegroups.com...
> Hello:
> I am working on a website that will require the use of multiple
> databases - a unique database for each user in fact. It is somewhat of
> a light CRM application and it is important to keep a user's customer
> information in their own database.
> So I am hoping to get input on the best way to implement this. The
> approach I am using so far includes storing the database connection
> string in a property of the user's profile object. However, this
> requires referencing the profile object each time I hit the database.
> And for pages that are using the sqldatasource control, that means
> assigning the connectionstring property for that control in the
> page_load event outside of an "if not page.ispostback" block. So I
> wonder if there isn't a better way.
> Any feedback would be really appreciated here.
> Chris
>|||How about storing the user's database name in their profile object and/or in
a session variable. Then you can prefix all of your calls with the database
name:
... "EXEC " + session("database_name") + ".dbo.ProcedureName";
Of course, if you are doing this for scalability reasons, you will probably
want to consider multiple connection strings for different servers...
<chrishalldba@.yahoo.com> wrote in message
news:1138581470.361914.172540@.o13g2000cwo.googlegroups.com...
> Hello:
> I am working on a website that will require the use of multiple
> databases - a unique database for each user in fact. It is somewhat of
> a light CRM application and it is important to keep a user's customer
> information in their own database.
> So I am hoping to get input on the best way to implement this. The
> approach I am using so far includes storing the database connection
> string in a property of the user's profile object. However, this
> requires referencing the profile object each time I hit the database.
> And for pages that are using the sqldatasource control, that means
> assigning the connectionstring property for that control in the
> page_load event outside of an "if not page.ispostback" block. So I
> wonder if there isn't a better way.
> Any feedback would be really appreciated here.
> Chris
>|||Aaron:
Thanks for your reply. I actually left out some stuff in my post to
keep the thread somewhat open-ended. Your suggestion actually looks
very close to what I ended up implementing. I am storing a database
connection string in a profile object, then loading that into a session
variable when the user logs in. It sounds like I'm on the right track
so that's reassuring. Thanks for the peace of mind!
Chris

Monday, March 12, 2012

How to configure a job for maintenance plan?

hello, everyone:
I have a maintenane plan to backup user database daily, How to configure a job to execute this plan daily? Thanks
zytLook up SQLMAINT or XP_SQLMAINT in BOL, depending on whether you want to run the job as OS command or T-SQL, respectively.

How to conditionally move field?

User enters a starting quarter and a year. I need to display 10 quarters and their years in line:
2005 . . . 2006
Q3 Q4 Q1 Q2 Q3 Q4 ...
Obviously, position of a year field will change based on whether we start from Q1 or from Q4.
Is there a way to do it?I'd probably put each variation in different sections and suppress each section accordingly.
Alternatively, use a non-proportional font and build up a string to display the year values with front space padding as required.

Friday, February 24, 2012

How to code an aspx page to run a stored procedure with a parameter

My stored proceddure "My Programs" includes a parameter @.meid.
How do I code an aspx file to run the procedure with a user ID, e.g. EmpID?
I tried the following codes, but the error message indicated it can not find
the Stored Procedure. How do I pass the EmpID as a Stored Procedure parameter?

<%
meid = EmpId
cmd.CommandText ="MyPrograms meid"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = sqlConnection2
sqlConnection2.Open()
reader3 = cmd.ExecuteReader(meid)
While reader3.Read()
sb.Append(reader3(i).ToString() +".....<BR> <BR /> ")
EndWhile
%>

TIA,
Jeffrey

Check if this helps:http://dotnetjunkies.com/WebLog/dinakar/articles/74220.aspx

|||

Thanks.

My co-worker told me I am supposed not need to know the parameter name, "@.meid".
Then what does "Failed to convert parameter value from a String to a Int32" mean?
Why the ExecuteReader() needs to convert EmpID to Int32? It's laready an integer.

TIA,
Jeffrey

<%
cmd.CommandText ="MyPrograms"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@.meid", SqlDbType.Int))
cmd.Parameters("@.meid").Value =EmpID
cmd.Connection = sqlConnection2
sqlConnection2.Open()
reader3 = cmd.ExecuteReader() Failed to convert parameter value from a String to a Int32.]

While reader3.Read()

sb.Append(reader3(i).ToString() +".....<BR> <BR /> ")

EndWhile

|||

I think I have solved the problem. The reason for the rror: "Failed to convert parameter value from a String to a Int32"
is Value = "EmpID". It should be EmpID.

Thanks gain.

Sunday, February 19, 2012

How to check/verify SQL login Credential

Hi,

I am making a module to backup SQL Db from webpage. I impersonate asp.net user to a given Windows Account and need to verify that account has required permission in SQL Server.

I don't know how to verify the windows account credential for SQL Server login.

Now what I am doing is to run SQL query against database to select row from some table, if it is successful, the user is valid SQL login. But I know it's not the way.

Any idea?

Thanks,

Why don't you just try to login and do the backup and if it fails you know you don't have permission