Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Tuesday, March 27, 2012

Adding a new VarBinaryMax column to an existing table using SMO.

Consider the following code.

Table applicationSettingsTable = database.Tables["application_settings"];

Column logoColumn = new Column(applicationSettingsTable, "logo", DataType.VarBinaryMax);

applicationSettingsTable.Columns.Add(logoColumn);

applicationSettingsTable.Alter();

I don't understand why - but when I execute this code I end up with a column that has the data type varbinary(1) in the database rather than varbinary(MAX). I can't see anything in the msdn documentation that tells me I need to do something special for varbinary(max) columns, but maybe I do?

Any help much appreciated.

This appears to work tho...

Column logoColumn = new Column(applicationSettingsTable, "logo", DataType.VarBinary(-1));

Sunday, March 25, 2012

Adding A default value in a column in a declare statment

Hi Can anybody help me.

I have this querey at the minute but when I attempt to put the default value of IND in the Sales Rep Code field I get an error Invalid column name, if I try and put 'IND' AS [Sales Rep Code] I get an incorrect syntax error.

DECLARE @.Query nVarchar(1000)
SET @.Query = N'SELECT NULL AS [GEO UNIT], NULL AS [PMC Invoice Date], IND AS [Sales Rep Code] FROM '+ 'Test' + RIGHT(DATEPART(yy, GETDATE()), 2) + '_' + CASE WHEN DATEPART(m, GETDATE()) IN ('11', '12', '1')
THEN 'Q1' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('2', '3', '4') THEN 'Q2' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('5', '6', '7')
THEN 'Q3' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('8', '9', '10') THEN 'Q4' END END END END + '.dbo.all_data' EXECUTE sp_executesql @.Query, N'@.level tinyint', @.level = 35

Can anybody please help on this.

ThanksHi Can anybody help me.

I have this querey at the minute but when I attempt to put the default value of IND in the Sales Rep Code field I get an error Invalid column name, if I try and put 'IND' AS [Sales Rep Code] I get an incorrect syntax error.

DECLARE @.Query nVarchar(1000)
SET @.Query = N'SELECT NULL AS [GEO UNIT], NULL AS [PMC Invoice Date], IND AS [Sales Rep Code] FROM '+ 'Test' + RIGHT(DATEPART(yy, GETDATE()), 2) + '_' + CASE WHEN DATEPART(m, GETDATE()) IN ('11', '12', '1')
THEN 'Q1' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('2', '3', '4') THEN 'Q2' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('5', '6', '7')
THEN 'Q3' ELSE CASE WHEN DATEPART(m, GETDATE()) IN ('8', '9', '10') THEN 'Q4' END END END END + '.dbo.all_data' EXECUTE sp_executesql @.Query, N'@.level tinyint', @.level = 35

Can anybody please help on this.

Thanks

would help us if u could post the ddl for the table|||what is the dataytpe of [Sales Rep Code]?
Off the cuff, it looks like your IND value is supposed to be a string.
Your example would be OK if you use 'IND' as [Sales Rep Code] - with the single quotes around IND.|||hi,

The datatype for SalesRep code is not defined as its in a view and I am creating the column [Sales Rep Code] with the default value of IND,

e.g

Select 'IND' AS [Sales Rep Code] from test would create a [Sales Rep Code] populated by IND for each row.

I have tried the 'IND' and it appears that it is incorrect syntax, this is beacuse it is closing the string value of the declare statment at the fist ' but I dont have a way around this.

Any Ideas|||Hi thanks for everyones help finally got it working but I still have one problem in that it is over 4000 carachters long and the @.test has a maximum of 4000 carachters is there any way around this.

Thanks

Thursday, March 22, 2012

adding a break for a /r, is it possible?

I have some data I'm getting back which has address details. The data is separated using a /r. In C# code you can obviously split the /r and replace this with a <br> tag to insert a break. Does anybody know how I can do this within reporting services, is it possible to write some expression to do this? Cheers.


Thanks

Use

=REPLACE(Fields!Address.Value, "/r", vbCrLf")

|||I've tried it and it doesn't work, I've added a quote before the replace vbCrLF but makes no difference|||

Sorry, it should be:

=REPLACE(Fields!Address.Value, "/r", vbCrLf)

No quotes as vbCrLf is a built in variable.

sql

Tuesday, March 20, 2012

Added a column to my SQL database and now text field will not write to it. Why

I have a web form that is an interface for a database. The code was working fine until a field needed to be added. So I added the new field, updated the data adapter and data set, and when i enter the data into the field, all of the old fields are getting updated, but the new ones aren't. I am at wits end as to why. Can someone please help!!!

I am using VS Studio 2000 ASP.NET and C#. The code is below. The bold items are the new fields.

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace TrafficDept

{

///<summary>

/// Summary description for AddOwner.

///</summary>

publicclass AddOwner : System.Web.UI.Page

{

protected System.Web.UI.WebControls.Button Button1;

protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;

protected System.Data.SqlClient.SqlConnection sqlConnection1;

protected System.Web.UI.WebControls.TextBox TextBox1;

protected System.Web.UI.WebControls.TextBox TextBox2;

protected System.Data.SqlClient.SqlDataAdapter daAddOwner;

protected System.Web.UI.WebControls.TextBox tbOtherOwnerLName;

protected System.Web.UI.WebControls.Panel namePanel;

protected System.Web.UI.WebControls.TextBox tbOtherOwnerMI;

protected System.Web.UI.WebControls.TextBox tbOtherOwnerFName;

protected System.Web.UI.WebControls.TextBox tbSecondOwnerLName;

protected System.Web.UI.WebControls.TextBox tbSecondOwnerMI;

protected System.Web.UI.WebControls.TextBox tbSecondOwnerFName;

protected System.Web.UI.WebControls.Button Button4;

protected SiteCubed.EditWorksProfessional tbNote;

protected System.Web.UI.WebControls.Panel notePanel;

protected System.Web.UI.WebControls.DropDownList ddlStatus;

protected PeterBlum.PetersDatePackage.DateTextBox tbRegDate;

protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;

protected System.Web.UI.WebControls.TextBox tbOwner;

protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;

protected System.Web.UI.WebControls.TextBox tbOwnerMI;

protected System.Web.UI.WebControls.TextBox tbOwnerLName;

protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;

protected System.Web.UI.WebControls.TextBox tbBusinessName;

protected System.Web.UI.WebControls.TextBox tbAddress;

protected System.Web.UI.WebControls.TextBox tbRegNo;

protected System.Web.UI.WebControls.TextBox tbPreviousOwner;

protected System.Web.UI.WebControls.TextBox tbPOwnerAddress;

protected System.Web.UI.WebControls.TextBox tbPORegNo;

protected PeterBlum.PetersDatePackage.DateTextBox tbTransferDate;

protected System.Web.UI.WebControls.DropDownList ddlMeans;

protected System.Web.UI.WebControls.Button Button3;

protected System.Web.UI.WebControls.Button Button2;

protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;

protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;

protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;

protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;

protected TrafficDept.dsAddOwner dsAddOwner1;

privatevoid Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

}

#region Web Form Designer generated code

privatevoid Button2_Click(object sender, System.EventArgs e)

{

Response.Redirect("AddOthers.aspx");

}

privatevoid Button1_Click(object sender, System.EventArgs e)

{

daAddOwner.Fill(dsAddOwner1);

dsAddOwner.OwnershipRow drOwner = dsAddOwner1.Ownership.NewOwnershipRow();

drOwner.Plates_ID =int.Parse(Session["PlatesID"].ToString());

drOwner.Status = ddlStatus.SelectedItem.Text;

drOwner.Current_Legal_Owner = tbOwner.Text;

drOwner.Owner_CurrentLegalOwnerMI = tbOwnerMI.Text.ToString();

drOwner.Owner_CurrentLegalOwnerLName = tbOwnerLName.Text;

drOwner.Owner_CurrentBusinessName = tbBusinessName.Text;

if (!tbRegDate.xIsEmpty)

drOwner.Date_of_Registration = DateTime.Parse(tbRegDate.Text.ToString());

drOwner.Address_of_Current_Owner = tbAddress.Text;

drOwner.Reg_No_for_Current_Owner = tbRegNo.Text;

drOwner.Previous_Owner = tbPreviousOwner.Text;

drOwner.Previous_Owner_Address = tbPOwnerAddress.Text;

drOwner.Reg_No_for_Previous_Owner = tbPORegNo.Text;

if (!tbTransferDate.xIsEmpty)

drOwner.Date_of_Transfer = DateTime.Parse(tbTransferDate.Text.ToString());

drOwner.By_Means_of = ddlMeans.SelectedItem.Text;

drOwner.Owner_SecondaryLegalOwnerFName = tbSecondOwnerFName.Text;

drOwner.Owner_SecondaryLegalOwnerMI = tbSecondOwnerMI.Text;

drOwner.Owner_SecondaryLegalOwnerLName = tbSecondOwnerLName.Text;

drOwner.Owner_OtherLegalOwnerFName = tbOtherOwnerFName.Text;

drOwner.Owner_OtherLegalOwnerMI = tbOtherOwnerMI.Text;

drOwner.Owner_OtherLegalOwnerLName = tbOtherOwnerLName.Text;

drOwner.Owner_Notes = tbNote.Text;

dsAddOwner1.Ownership.Rows.Add(drOwner);

daAddOwner.Update(dsAddOwner1);

Response.Redirect("AddOthersTP.aspx");

}

privatevoid Button3_Click(object sender, System.EventArgs e)

{

//daAddOwner.Fill(dsAddOwner1);

//dsAddOwner.OwnershipRow drAddOwner = dsAddOwner1.Ownership.NewOwnershipRow();

namePanel.Visible =true;

}

privatevoid Button4_Click(object sender, System.EventArgs e)

{

notePanel.Visible =true;

}

}

}

I found my problem. The .dll was never being rebuilt.

AddcurrentRange ?

Report.ParameterFields(4).AddCurrentRange "000", "999", 3
In this line of code, what does number 3 stands for ? 000 is start and 999 is end range I presume, but number 3 is a mistery 2 me.According to info I found :

"Use this bitwise value to indicate whether the upper and/or lower bound of the range should be included".

I'm not sure which value indicates what, though.

Hope this helps.|||http://support.businessobjects.com/library/kbase/articles/c2007345.asp :

'crRangeNotIncludeUpperLowerBound 0
'crRangeIncludeLowerBound 2
'crRangeIncludeUpperBound 1
'crRangeNoLowerBound 8
'crRangeNoUpperBound 4

I would guess the value 3 probably means include both upper and lower?

Monday, March 19, 2012

Add User/Set Roles in Code and Read Roles

Can you write a stored procedure to add a user to your DB and set the roles the user belongs to?

I want to write a stored proc. to add users and set roles so it can be used in code instead of doing it manually.

After the user has been added and their roles set, can you write another stored proc. to give you what roles they belong to?Look for following sprocs in BOL and sp_helptext sprocs in QA

Might be a big help

sp_helprole
sp_helprotect
sp_helprolemember

sp_addrole
sp_addrolemember

However something you might need to check out

The Holy Book says:
sp_addrole cannot be used inside a user-defined transaction.|||insert into sysusers values
('new_user_id', 0, 'new_role_name', NULL, 0x00, getdate(), getdate(), 'dbo', NULL)|||Originally posted by Enigma
Look for following sprocs in BOL and sp_helptext sprocs in QA

Might be a big help

sp_helprole
sp_helprotect
sp_helprolemember

sp_addrole
sp_addrolemember

However something you might need to check out

The Holy Book says:
sp_addrole cannot be used inside a user-defined transaction.
sp_grantlogin, sp_grantdbaccess, sp_addrolemember, and sp_helpuser worked great. thanks.

add to data

Hi All,
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
SteveHi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.

add to data

Hi All,
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
Steve
Hi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.

add to data

Hi All,
I have a database that has a field with phone numbers in.
I want to update the main part of the number to add the area code to
the main number.
I will do a selection on the postcode of the address and then I want to
add the correct area code to the beginning of the number.
Any help please.
SteveHi Steve,
First of all:
http://www.aspfaq.com/etiquette.asp?id=5006
Based on this its hard to give some suggestions but assuming some thing
here is some pseudocode
UPDATE CustomerTable
SET phoneNumber = CAST(RegionCode AS VARCHAR(10)) + CAST(phoneNumber
AS VARCHAR(100))
FROM CustomerTable C
INNER JOIN
RegionPhoeTable R
ON C.ZipCode = R.ZipCode
HTH, jens Suessmeyer.

Sunday, March 11, 2012

Add scripttask script programmatically

I'm building packages programmatically. I need to add a ScriptTask to my package and include the script code. The script task itself is easy to add. But I can't figure out how to add the script code to the task.

I found one post in this forum saying the trick is to use the PutSourceCode method of the StriptTaskCodeProvider class, but I can't figure out how to do that.

Can anyone provide a code sample of how this is done?

Thanks.

After looking into this more deeply I found that adding a Script Task is a large job and I opted for a simpler approach to my particular issue. A lot of code needs to be added into the package. You have to create a VSA project, then add the script code it contains. To see an example of what's required, open a .dtsx file containing a Script Task and look for the tag "ScriptProject Name", and examine the ProjectItems it contains.

In case it is of use to anyone in the future, here's what I came up with. This doesn't create both the project and the script code because I didn't go that far, but it shows you the references and objects you'll need to do that.

Add references to Microsoft.SqlServer.ScriptTask and Microsoft.SqlServer.VSAHosting.

Dim exe As Executable = _Package.Executables.Add("STOCK:ScriptTask")

Dim thTask As TaskHost = CType(exe, TaskHost)

thTask.Name = "MyScriptTask"

Dim st As ScriptTask = TryCast(thTask.InnerObject, ScriptTask)

dim Moniker as String = "dts://Scripts/" & st.VsaProjectName & "/" & st.VsaProjectName & ".vsaproj"

st.ReadWriteVariables = "Var1, Var2"

Dim sb As New StringBuilder

sb.AppendLine("'Microsoft SQL Server Integration Services Script Task")

'build your code here

'this inserts the code into the script task

st.CodeProvider.PutSourceCode(Moniker, sb.ToString)

Thursday, March 8, 2012

Add New Row Problems

This code runs with no errors.
The problem is nothing actually gets updated.

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim mEmp As New YessClass1
Dim EmpID As Long
Dim Conn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

'Dim mRdg As YessClass1 = New YessClass1
Dim lngID As Long
'This is to save a record to tblFeedback
Dim strSelect As String = "SELECT * FROM tblFeedback"
'now create the data adapter object and connect it to
'sql string and the connection
Dim dscmd As New SqlDataAdapter(strSelect, Conn)
' Load a data set.
ds = New DataSet
'data Adapter fill with dataset, name of dataset
dscmd.Fill(ds, "Feedback")
SqlConnection1.Close()
'get the EmployeeID and the Rounding RecordID
Try
mEmp = CType(Session("objEmp"), YessClass1)
EmpID = mEmp.Employee
Try
Dim dt As DataTable = ds.Tables.Item("FeedBack")
Dim rowFeedback As DataRow = dt.NewRow

With rowFeedback
.Item("RoundingID") = RdgID
.Item("QuestionID") = Me.lstQuestion.SelectedItem.Value
.Item("ResponseActionID") = Me.lstAction.SelectedItem.Value
.Item("EmployeeID") = Me.lstDirector.SelectedItem.Value
.Item("ActivityID") = Me.lstActivity.SelectedItem.Value
.Item("Feedback") = Me.txtFeedback.Text
If Me.ckReq.Checked = True Then
.Item("Acknowledgement") = 1
.Item("AckDate") = Now
End If
End With

dt.Rows.Add(rowFeedback)

Catch ex As Exception

Response.Write("Error occured" & ex.Message)
End Try
Catch ex As Exception
Response.Write("ERROR: " & ex.Message)
End Try
End SubWhere are you actually updating the database? Adding the row to the DataTable does not do it. You need to call .Update somewhere on the DataSet.

Tuesday, March 6, 2012

Add javascript code to report page inside the report manager

Hi all,
Does anyone knows how can I add some javascript code into the html page
which contains a report into the report manager?.
Let's the following scenario, suppose that any user wants to execute some
reports from report manager, first the user goes to http://server/reports
after that he/she will be at home page configured due to his/her profile, the
user select a report with a click and, he/she executes it. The report will be
rendered in html inside the same window where the report manager is, but in
different frame.
I know using both htc and css files I can modify some behavior of the html
page but, the problem is that both report manager and the rendered report
coexist in the same window( I mean different frames for each of them ) I
don't know how to add some javascript code into the frame or page or whatever
the report lives in.
Any help will be appreciated.Hi
in the htc you can access the frame page which contain the report and the
report manager using the javascript dhtml code.
you can use like
frame[0].document.
or window.document.getelementbyID['asd'].
you dont have to insert script in the frame
you can put all the code in htc to call the code..
"jhcp" wrote:
> Hi all,
> Does anyone knows how can I add some javascript code into the html page
> which contains a report into the report manager?.
> Let's the following scenario, suppose that any user wants to execute some
> reports from report manager, first the user goes to http://server/reports
> after that he/she will be at home page configured due to his/her profile, the
> user select a report with a click and, he/she executes it. The report will be
> rendered in html inside the same window where the report manager is, but in
> different frame.
> I know using both htc and css files I can modify some behavior of the html
> page but, the problem is that both report manager and the rendered report
> coexist in the same window( I mean different frames for each of them ) I
> don't know how to add some javascript code into the frame or page or whatever
> the report lives in.
> Any help will be appreciated.|||Hi Bava,
thanks for your answer but, how can I know which frame contains the rendered
report?.
The htc file I coded is the following
<public:component tagName="test1">
<PUBLIC:ATTACH EVENT="oncontextmenu" onevent="f_CancelEvent()" />
<PUBLIC:ATTACH EVENT="onselectstart" onevent="f_CancelEvent()" />
<PUBLIC:ATTACH EVENT="ondragstart" onevent="f_CancelEvent()" />
</public:component>
<SCRIPT language="javascript">
function f_CancelEvent()
{
event.returnValue = false;
}
</script>
After that, I reference that piece of code in a css file as following
body {
margin: 0;
background-color: White;
font-family: Verdana, Sans-Serif;
font-size: x-small;
behavior: url(../js/test1.htc);
}
"Bava Mani" wrote:
> Hi
> in the htc you can access the frame page which contain the report and the
> report manager using the javascript dhtml code.
> you can use like
> frame[0].document.
> or window.document.getelementbyID['asd'].
> you dont have to insert script in the frame
> you can put all the code in htc to call the code..
> "jhcp" wrote:
> > Hi all,
> > Does anyone knows how can I add some javascript code into the html page
> > which contains a report into the report manager?.
> > Let's the following scenario, suppose that any user wants to execute some
> > reports from report manager, first the user goes to http://server/reports
> > after that he/she will be at home page configured due to his/her profile, the
> > user select a report with a click and, he/she executes it. The report will be
> > rendered in html inside the same window where the report manager is, but in
> > different frame.
> > I know using both htc and css files I can modify some behavior of the html
> > page but, the problem is that both report manager and the rendered report
> > coexist in the same window( I mean different frames for each of them ) I
> > don't know how to add some javascript code into the frame or page or whatever
> > the report lives in.
> > Any help will be appreciated.|||Hi,
are you using 2000 or 2005 reporting service?
in 2000 there is only one iframe so you can just use
window.frames.item(0)
or
window.document.getElementById(framid) if it is 2005
hope it helps
"jhcp" wrote:
> Hi Bava,
> thanks for your answer but, how can I know which frame contains the rendered
> report?.
> The htc file I coded is the following
> <public:component tagName="test1">
> <PUBLIC:ATTACH EVENT="oncontextmenu" onevent="f_CancelEvent()" />
> <PUBLIC:ATTACH EVENT="onselectstart" onevent="f_CancelEvent()" />
> <PUBLIC:ATTACH EVENT="ondragstart" onevent="f_CancelEvent()" />
> </public:component>
> <SCRIPT language="javascript">
> function f_CancelEvent()
> {
> event.returnValue = false;
> }
> </script>
> After that, I reference that piece of code in a css file as following
> body {
> margin: 0;
> background-color: White;
> font-family: Verdana, Sans-Serif;
> font-size: x-small;
> behavior: url(../js/test1.htc);
> }
>
> "Bava Mani" wrote:
> > Hi
> > in the htc you can access the frame page which contain the report and the
> > report manager using the javascript dhtml code.
> > you can use like
> > frame[0].document.
> > or window.document.getelementbyID['asd'].
> > you dont have to insert script in the frame
> > you can put all the code in htc to call the code..
> >
> > "jhcp" wrote:
> >
> > > Hi all,
> > > Does anyone knows how can I add some javascript code into the html page
> > > which contains a report into the report manager?.
> > > Let's the following scenario, suppose that any user wants to execute some
> > > reports from report manager, first the user goes to http://server/reports
> > > after that he/she will be at home page configured due to his/her profile, the
> > > user select a report with a click and, he/she executes it. The report will be
> > > rendered in html inside the same window where the report manager is, but in
> > > different frame.
> > > I know using both htc and css files I can modify some behavior of the html
> > > page but, the problem is that both report manager and the rendered report
> > > coexist in the same window( I mean different frames for each of them ) I
> > > don't know how to add some javascript code into the frame or page or whatever
> > > the report lives in.
> > > Any help will be appreciated.|||Hi Bava,
I'm using SSRS 2000.
Actually, I don't know how can I reference the iframe from htc file. Let me
explain.
What I want to do is to disable select any text or image inside the report
frame and, disable contextual menu too, that's why I posted the code
yesterday.
Could you please help me to do that?
I really appreciated your help.
"Bava Mani" wrote:
> Hi,
> are you using 2000 or 2005 reporting service?
> in 2000 there is only one iframe so you can just use
> window.frames.item(0)
> or
> window.document.getElementById(framid) if it is 2005
> hope it helps
> "jhcp" wrote:
> > Hi Bava,
> > thanks for your answer but, how can I know which frame contains the rendered
> > report?.
> > The htc file I coded is the following
> >
> > <public:component tagName="test1">
> > <PUBLIC:ATTACH EVENT="oncontextmenu" onevent="f_CancelEvent()" />
> > <PUBLIC:ATTACH EVENT="onselectstart" onevent="f_CancelEvent()" />
> > <PUBLIC:ATTACH EVENT="ondragstart" onevent="f_CancelEvent()" />
> > </public:component>
> > <SCRIPT language="javascript">
> > function f_CancelEvent()
> > {
> > event.returnValue = false;
> > }
> > </script>
> > After that, I reference that piece of code in a css file as following
> >
> > body {
> > margin: 0;
> > background-color: White;
> > font-family: Verdana, Sans-Serif;
> > font-size: x-small;
> > behavior: url(../js/test1.htc);
> > }
> >
> >
> >
> > "Bava Mani" wrote:
> >
> > > Hi
> > > in the htc you can access the frame page which contain the report and the
> > > report manager using the javascript dhtml code.
> > > you can use like
> > > frame[0].document.
> > > or window.document.getelementbyID['asd'].
> > > you dont have to insert script in the frame
> > > you can put all the code in htc to call the code..
> > >
> > > "jhcp" wrote:
> > >
> > > > Hi all,
> > > > Does anyone knows how can I add some javascript code into the html page
> > > > which contains a report into the report manager?.
> > > > Let's the following scenario, suppose that any user wants to execute some
> > > > reports from report manager, first the user goes to http://server/reports
> > > > after that he/she will be at home page configured due to his/her profile, the
> > > > user select a report with a click and, he/she executes it. The report will be
> > > > rendered in html inside the same window where the report manager is, but in
> > > > different frame.
> > > > I know using both htc and css files I can modify some behavior of the html
> > > > page but, the problem is that both report manager and the rendered report
> > > > coexist in the same window( I mean different frames for each of them ) I
> > > > don't know how to add some javascript code into the frame or page or whatever
> > > > the report lives in.
> > > > Any help will be appreciated.

Saturday, February 25, 2012

Add ID at Insert

The below code works fine, but for one reason, I need to get the ReferenceID inserted into a seperate table along with the newly created unique ID in the table Box. Any ideas how I can accomplish this...


CREATE PROCEDURE AddBox
(
@.BoxNumber nvarchar(40),
@.LocId int,
@.BoxNotes Text,
--This gets added to a different table that I'll call References, but can't go until I can get the uniqueID of what is inserted.
@.ReferenceID int
)

AS

INSERT INTO box
(
box_num,
loc_id,
box_notes,
status_id
)

VALUES
(
@.BoxNumber,
@.Locid,
@.BoxNotes,
2
)

didnt quite understand your question but check out BOL for SCOPE_IDENTITY().

hth|||Just the point in the right direction I needed, Thanks.

Once I inserted a new box file into the Box table I then was able to get the Unique ID number and then insert that into a reference table. The end code (after the first insert) for my previous post ends up looking as such:

Set @.Identity = SCOPE_IDENTITY()
Set @.Reference = @.ReferenceNumber
Insert into reference
(
reference_name,
box_id
)
VALUES
(
@.Reference,
@.Identity
)
GO

Add events as one batch

Hi,

Can I add collection of events to notification services from my .NET application?

Current implementation in my code:

Code Snippet

// create a new event and event collector

Event myEvent = new Event(application, eventClassName);

EventCollector eventCollector = new EventCollector(application, EVENT_CREATOR);

// Set field values of the event.

.

.

.

// add the event

eventCollector.Write(myEvent);

// commit the 1-event batch

eventCollector.Commit();

Let me know how can I commit collection of events at once rather than one by one.

Please give me your suggestions on this whether this can not be achieved or NOT.

Thanks in advance

Yogendran

Ah... Guys do you know where I can get the answer for this question?

Please help me.

Do you think this cann't be done?

Regards

Yogendran

Thursday, February 16, 2012

Add a user via a script

Hello All, I've got a script that will Create a Database and install the
tables onto a SQL server.
what code is used to add a user/username and password to allow the user to
login?
I am aware that I can do this from the SQL Server, However, I've been asked
to do it in the code.
I don't want to add a user to the network - just into 1 database. I think
this eliminates that code ( sp_grantdbaccess & sp_grantlogin)
I've looked at CreateUser. However when I try to run this I get an error
saying, "Could not find stored procedure 'createuser'"
Please help
TIA
Woody
Chris
--Creating logins and granting them access to database
SET @.login='bbbbbbbbbbbbbb'
SET @.pass='aaaaaaaaaaaaaaaa'
SET @.db=@.name
IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname=@.login)
BEGIN
EXEC sp_addlogin @.loginame = @.login, @.passwd =@.pass, @.defdb = @.db
END
SET @.sql_db='USE '+@.name
SET @.sql1=(' IF NOT EXISTS (SELECT * FROM sysusers WHERE name=
'''+@.login+''')')
SET @.sql2=(' BEGIN EXEC sp_grantdbaccess '''+@.login+'''')
SET @.sql3=(' EXEC sp_addrolemember ''db_owner'','''+@.login+''' END')
EXEC (@.sql_db+@.sql1+@.sql2+@.sql3)
"Chris" <a@.b.com> wrote in message
news:eMEQW7nIGHA.3036@.tk2msftngp13.phx.gbl...
> Hello All, I've got a script that will Create a Database and install the
> tables onto a SQL server.
> what code is used to add a user/username and password to allow the user to
> login?
> I am aware that I can do this from the SQL Server, However, I've been
> asked
> to do it in the code.
> I don't want to add a user to the network - just into 1 database. I
> think
> this eliminates that code ( sp_grantdbaccess & sp_grantlogin)
> I've looked at CreateUser. However when I try to run this I get an error
> saying, "Could not find stored procedure 'createuser'"
>
> Please help
> TIA
> Woody
>
|||Hi Uri, thanks for the reply.
I'm having a little trouble running it though.
SET @.login='bbbbbbbbbbbbbb'
Server: Msg 137, Level 15, State 1, Line 2
Must declare the variable '@.login'.
please advise.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:uuYHr9nIGHA.2064@.TK2MSFTNGP09.phx.gbl...
> Chris
> --Creating logins and granting them access to database
> SET @.login='bbbbbbbbbbbbbb'
> SET @.pass='aaaaaaaaaaaaaaaa'
> SET @.db=@.name
> IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE
loginname=@.login)[vbcol=seagreen]
> BEGIN
> EXEC sp_addlogin @.loginame = @.login, @.passwd =@.pass, @.defdb = @.db
> END
> SET @.sql_db='USE '+@.name
> SET @.sql1=(' IF NOT EXISTS (SELECT * FROM sysusers WHERE name=
> '''+@.login+''')')
> SET @.sql2=(' BEGIN EXEC sp_grantdbaccess '''+@.login+'''')
> SET @.sql3=(' EXEC sp_addrolemember ''db_owner'','''+@.login+''' END')
> EXEC (@.sql_db+@.sql1+@.sql2+@.sql3)
>
>
>
>
> "Chris" <a@.b.com> wrote in message
> news:eMEQW7nIGHA.3036@.tk2msftngp13.phx.gbl...
to
>

Add a user via a script

Hello All, I've got a script that will Create a Database and install the
tables onto a SQL server.
what code is used to add a user/username and password to allow the user to
login?
I am aware that I can do this from the SQL Server, However, I've been asked
to do it in the code.
I don't want to add a user to the network - just into 1 database. I think
this eliminates that code ( sp_grantdbaccess & sp_grantlogin)
I've looked at CreateUser. However when I try to run this I get an error
saying, "Could not find stored procedure 'createuser'"
Please help
TIA
WoodyChris
--Creating logins and granting them access to database
SET @.login='bbbbbbbbbbbbbb'
SET @.pass='aaaaaaaaaaaaaaaa'
SET @.db=@.name
IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname=@.login)
BEGIN
EXEC sp_addlogin @.loginame = @.login, @.passwd =@.pass, @.defdb = @.db
END
SET @.sql_db='USE '+@.name
SET @.sql1=(' IF NOT EXISTS (SELECT * FROM sysusers WHERE name=
'''+@.login+''')')
SET @.sql2=(' BEGIN EXEC sp_grantdbaccess '''+@.login+'''')
SET @.sql3=(' EXEC sp_addrolemember ''db_owner'','''+@.login+''' END')
EXEC (@.sql_db+@.sql1+@.sql2+@.sql3)
"Chris" <a@.b.com> wrote in message
news:eMEQW7nIGHA.3036@.tk2msftngp13.phx.gbl...
> Hello All, I've got a script that will Create a Database and install the
> tables onto a SQL server.
> what code is used to add a user/username and password to allow the user to
> login?
> I am aware that I can do this from the SQL Server, However, I've been
> asked
> to do it in the code.
> I don't want to add a user to the network - just into 1 database. I
> think
> this eliminates that code ( sp_grantdbaccess & sp_grantlogin)
> I've looked at CreateUser. However when I try to run this I get an error
> saying, "Could not find stored procedure 'createuser'"
>
> Please help
> TIA
> Woody
>|||Hi Uri, thanks for the reply.
I'm having a little trouble running it though.
SET @.login='bbbbbbbbbbbbbb'
Server: Msg 137, Level 15, State 1, Line 2
Must declare the variable '@.login'.
please advise.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:uuYHr9nIGHA.2064@.TK2MSFTNGP09.phx.gbl...
> Chris
> --Creating logins and granting them access to database
> SET @.login='bbbbbbbbbbbbbb'
> SET @.pass='aaaaaaaaaaaaaaaa'
> SET @.db=@.name
> IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE
loginname=@.login)
> BEGIN
> EXEC sp_addlogin @.loginame = @.login, @.passwd =@.pass, @.defdb = @.db
> END
> SET @.sql_db='USE '+@.name
> SET @.sql1=(' IF NOT EXISTS (SELECT * FROM sysusers WHERE name=
> '''+@.login+''')')
> SET @.sql2=(' BEGIN EXEC sp_grantdbaccess '''+@.login+'''')
> SET @.sql3=(' EXEC sp_addrolemember ''db_owner'','''+@.login+''' END')
> EXEC (@.sql_db+@.sql1+@.sql2+@.sql3)
>
>
>
>
> "Chris" <a@.b.com> wrote in message
> news:eMEQW7nIGHA.3036@.tk2msftngp13.phx.gbl...
to[vbcol=seagreen]
>

Add a user via a script

Hello All, I've got a script that will Create a Database and install the
tables onto a SQL server.
what code is used to add a user/username and password to allow the user to
login?
I am aware that I can do this from the SQL Server, However, I've been asked
to do it in the code.
I don't want to add a user to the network - just into 1 database. I think
this eliminates that code ( sp_grantdbaccess & sp_grantlogin)
I've looked at CreateUser. However when I try to run this I get an error
saying, "Could not find stored procedure 'createuser'"
Please help
TIA
WoodyChris
--Creating logins and granting them access to database
SET @.login='bbbbbbbbbbbbbb'
SET @.pass='aaaaaaaaaaaaaaaa'
SET @.db=@.name
IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname=@.login)
BEGIN
EXEC sp_addlogin @.loginame = @.login, @.passwd =@.pass, @.defdb = @.db
END
SET @.sql_db='USE '+@.name
SET @.sql1=(' IF NOT EXISTS (SELECT * FROM sysusers WHERE name='''+@.login+''')')
SET @.sql2=(' BEGIN EXEC sp_grantdbaccess '''+@.login+'''')
SET @.sql3=(' EXEC sp_addrolemember ''db_owner'','''+@.login+''' END')
EXEC (@.sql_db+@.sql1+@.sql2+@.sql3)
"Chris" <a@.b.com> wrote in message
news:eMEQW7nIGHA.3036@.tk2msftngp13.phx.gbl...
> Hello All, I've got a script that will Create a Database and install the
> tables onto a SQL server.
> what code is used to add a user/username and password to allow the user to
> login?
> I am aware that I can do this from the SQL Server, However, I've been
> asked
> to do it in the code.
> I don't want to add a user to the network - just into 1 database. I
> think
> this eliminates that code ( sp_grantdbaccess & sp_grantlogin)
> I've looked at CreateUser. However when I try to run this I get an error
> saying, "Could not find stored procedure 'createuser'"
>
> Please help
> TIA
> Woody
>|||Hi Uri, thanks for the reply.
I'm having a little trouble running it though.
SET @.login='bbbbbbbbbbbbbb'
Server: Msg 137, Level 15, State 1, Line 2
Must declare the variable '@.login'.
please advise.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:uuYHr9nIGHA.2064@.TK2MSFTNGP09.phx.gbl...
> Chris
> --Creating logins and granting them access to database
> SET @.login='bbbbbbbbbbbbbb'
> SET @.pass='aaaaaaaaaaaaaaaa'
> SET @.db=@.name
> IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE
loginname=@.login)
> BEGIN
> EXEC sp_addlogin @.loginame = @.login, @.passwd =@.pass, @.defdb = @.db
> END
> SET @.sql_db='USE '+@.name
> SET @.sql1=(' IF NOT EXISTS (SELECT * FROM sysusers WHERE name=> '''+@.login+''')')
> SET @.sql2=(' BEGIN EXEC sp_grantdbaccess '''+@.login+'''')
> SET @.sql3=(' EXEC sp_addrolemember ''db_owner'','''+@.login+''' END')
> EXEC (@.sql_db+@.sql1+@.sql2+@.sql3)
>
>
>
>
> "Chris" <a@.b.com> wrote in message
> news:eMEQW7nIGHA.3036@.tk2msftngp13.phx.gbl...
> >
> > Hello All, I've got a script that will Create a Database and install the
> > tables onto a SQL server.
> > what code is used to add a user/username and password to allow the user
to
> > login?
> > I am aware that I can do this from the SQL Server, However, I've been
> > asked
> > to do it in the code.
> > I don't want to add a user to the network - just into 1 database. I
> > think
> > this eliminates that code ( sp_grantdbaccess & sp_grantlogin)
> >
> > I've looked at CreateUser. However when I try to run this I get an error
> > saying, "Could not find stored procedure 'createuser'"
> >
> >
> > Please help
> > TIA
> > Woody
> >
> >
>

Thursday, February 9, 2012

ActiveX Vbscript still ok in Yukon ?

Will I still be able to use my current VBscripts (Active X) code in dts
packages in Yukon ?Hi
In SQL Server 2005, there is an optional install of the SQL Server 2000 DTS
engine. this will allow the existing scripts to work (as long as you don't
use any T-SQL that is no longer supported in SQL Server 2005).
The new DTS engine in SQL Server 2005 is amazing and you will be very
tempted to convert your existing packages ASAP to the new engine.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Rob C" <rwc1960@.bellsouth.net> wrote in message
news:I81xd.21621$rO2.720@.bignews1.bellsouth.net...
> Will I still be able to use my current VBscripts (Active X) code in dts
> packages in Yukon ?
>