Showing posts with label delete. Show all posts
Showing posts with label delete. Show all posts

Sunday, March 25, 2012

cant show data from my database

Hi

I have this code, but i can't get it to work, and if i delete <% %> then the if statsment is not working, how do i get this code to work.

1<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringMain%>"2 SelectCommand="SELECT [SiteMainID], [SiteMainText] FROM [MainSiteText] WHERE ([SiteMainID] = @.SiteMainID)">3<% Dim pageString As String = "Def"4 If Not (Request.QueryString("Page") Is Nothing) Then5 pageString = Request.QueryString("Page").ToString6 End If7 If pageString = "Def" Then8%>9 <SelectParameters>10 <asp:Parameter DefaultValue="1" Name="SiteMainID" Type="Int32" />11 </SelectParameters>12<%13 Else14 If pageString = "Page1" Then15%>16 <SelectParameters>17 <asp:Parameter DefaultValue="2" Name="SiteMainID" Type="Int32" />18 </SelectParameters>19<%20 Else21 If pageString = "Page2" Then22%>23 <SelectParameters>24 <asp:Parameter DefaultValue="3" Name="SiteMainID" Type="Int32" />25 </SelectParameters>26<%2728 End If29 End If30%>31</asp:SqlDataSource>

you can do it your sql if you want

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringMain%>"SelectCommand="SELECT [SiteMainID], [SiteMainText] FROM [MainSiteText] WHERE [SiteMainID] = (

SelectCase @.SiteMainIDWhen'Page1'Then 2When'Page2'Then 3Else 1End)">
<SelectParameters>
<asp:QueryStringParameterQueryStringField="Page"DefaultValue="Def"Name="SiteMainID"Type="String"/>
</SelectParameters>
|||

this might work too...

First remove all the code below the initial sqldatasource control code. in other words all the parameter code stuff.

Protected Sub SqlDataSource1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles SqlDataSource1.Init
Dim pageString As String = "Def"
If Not (Request.QueryString("Page") Is Nothing) Then
pageString = Request.QueryString("Page").ToString
End If
SqlDataSource1.SelectParameters.Clear()
If pageString = "Def" Then
SqlDataSource1.SelectParameters.Add(New WebControls.Parameter("SiteMainID", TypeCode.Int32, "1"))
Else
If pageString = "Page1" Then
SqlDataSource1.SelectParameters.Add(New WebControls.Parameter("SiteMainID", TypeCode.Int32, "2"))
ElseIf pageString = "Page2" Then
SqlDataSource1.SelectParameters.Add(New WebControls.Parameter("SiteMainID", TypeCode.Int32, "3"))
End If
End If
End Sub

|||

if u mean like this, then i get a codeblock error for the <% thats its not supported in this context:

1<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringMain%>"2 SelectCommand="SELECT [SiteMainID], [SiteMainText] FROM [MainSiteText] WHERE ([SiteMainID] = @.SiteMainID)">3<%4 Protected Sub SqlDataSource1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles SqlDataSource1.Init5 Dim pageString As String = "Def"6 If Not (Request.QueryString("Page") Is Nothing) Then7 pageString = Request.QueryString("Page").ToString8 End If9 SqlDataSource1.SelectParameters.Clear()10 If pageString = "Def" Then11 SqlDataSource1.SelectParameters.Add(New WebControls.Parameter("SiteMainID", TypeCode.Int32, "1"))12 Else13 If pageString = "Page1" Then14 SqlDataSource1.SelectParameters.Add(New WebControls.Parameter("SiteMainID", TypeCode.Int32, "2"))15 ElseIf pageString = "Page2" Then16 SqlDataSource1.SelectParameters.Add(New WebControls.Parameter("SiteMainID", TypeCode.Int32, "3"))17 End If18 End If19 End Sub20%>21</asp:SqlDataSource>

|||

Cant i use session !?

Like this:

<asp:Content ID="Main" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server"><% Dim pageString As String = "Def" Dim PageID = CType(Session("pageid"), Integer) If Not (Request.QueryString("Page") Is Nothing) Then pageString = Request.QueryString("Page").ToString End If If pageString = "Def" Then PageID = "1" Else If pageString = "Page2" Then PageID = "2" Else If pageString = "Page3" Then PageID = "3" End If End If End If%><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringMain%>" SelectCommand="SELECT [SiteMainID], [SiteMainText] FROM [MainSiteText] WHERE ([SiteMainID] = '" & Session("pageid") & "')"></asp:SqlDataSource>
my only problem with this is that i get a "Attribute 'session' is not a valid attribute of the element 'SqlDateSource'"|||

Yes

You could bind SelectCommand to Session.

But I would do it in SqlDataSource1_DataBinding Event:

protected void SqlDataSource1_DataBinding(object sender, EventArgs e) { String sql ="SELECT column1 FROM test WHERE column1 ='" + Session["pageid"] +"'"; SqlDataSource1.SelectCommand = sql; }

You need to change it to VB.

Hope this helps.

Sunday, March 11, 2012

Can't Run any DM Until Delete Lost Cube? (even when I start a new Project from scratch!!)

Can't Run any DM Until Delete Lost Cube?

Even if I start a new Project from scratch I get the same error,

Even if in the new Project I press "start debug" before I create anything.

There is no connection, no data source view, no ...

Can you provide more details?

What error are you seeing? Are you seeing this error in Business Intelligence Development Studio?

Can't Run any DM Until Delete Lost Cube?

I (unsuccessfully) made a cube named, MSR TRANCHES. I can't find any trace of it anymore. However, I can't make a new Mining Structure because VS complains of:

Error 1 File system error: Error opening file; \\?\C:\Program Files\Microsoft SQL Server\MSSQL.2\OLAP\Data\Analysis Services Project1.0.db\MSR TRANCHES ~MC.1.cub.xml is not a disk file or file is not accessible. Errors in the metadata manager. An error occurred when loading the MSR TRANCHES ~MC cube, from the file, '\\?\C:\Program Files\Microsoft SQL Server\MSSQL.2\OLAP\Data\Analysis Services Project1.0.db\MSR TRANCHES ~MC.1.cub.xml'. 0 0

I can't find any cube anywhere, nor do I find this missing file. How does Visual Studio know to look and how do I clear this up.

Thank you very much,

I obtain the same error when I try to develop a mining structure. Anybody know the solution?

Thanks in advance.

|||The error you're seeing indicates that the database is corrupt (internal files associated with certain system objects are missing). If you don't have any other database/objects you need to save on the server, the workaround would be to shut down the AS2005 service (SQL Server Analysis Service (<instancename>)), delete the "\Program Files\Microsoft SQL Server\MSSQL.x\OLAP\Data" folder and restart the service.

Thursday, March 8, 2012

Can't remove SA account or delete xp_cmdshell ext stored proc?

I'm trying to make my SQL Server a tad more secure, but I'm unable to remove
SA (I'm running Mixed mode) -- can the SA account only be removed when using
windows Authentication? When I try to remove SA I get "selected user
cannot be dropped because the user owns objects". When I try to delect
xp_cmdshell I get the following error "You tried to delete one or more
system objects. They were not deleted."
I must admit, I'm a little confused, I'm trying to implement Microsofts
security recommendations, but either the documention is not
detailed/accurate or I'm missing something?
Any suggestions?
Thanks, Rob.Hi
You can not remove the SA account. Set a very complicated password for it,
write it down and put it in a safe.
For the xp_ look at
http://support.microsoft.com/defaul...kb;en-us;891984
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Rob R. Ainscough" wrote:

> I'm trying to make my SQL Server a tad more secure, but I'm unable to remo
ve
> SA (I'm running Mixed mode) -- can the SA account only be removed when usi
ng
> windows Authentication? When I try to remove SA I get "selected user
> cannot be dropped because the user owns objects". When I try to delect
> xp_cmdshell I get the following error "You tried to delete one or more
> system objects. They were not deleted."
> I must admit, I'm a little confused, I'm trying to implement Microsofts
> security recommendations, but either the documention is not
> detailed/accurate or I'm missing something?
> Any suggestions?
> Thanks, Rob.
>
>
>|||> I'm trying to make my SQL Server a tad more secure, but I'm unable to
> remove SA (I'm running Mixed mode) -- can the SA account only be removed
> when using windows Authentication? When I try to remove SA I get
> "selected user cannot be dropped because the user owns objects". When I
> try to delect xp_cmdshell I get the following error "You tried to delete
> one or more system objects. They were not deleted."
The sa login account cannot be deleted or renameed, nor it can't be revoked
any permission.

> I must admit, I'm a little confused, I'm trying to implement Microsofts
> security recommendations, but either the documention is not
> detailed/accurate or I'm missing something?
I don't think MS ever mentioned droping the sa account (as it can't be
done). Here are recommendations from Operations Guide: "
The sa account in a production environment should be given a complex
password, made up of uppercase and lowercase letters, symbols, spaces, and
numbers. The sa account should have a complex password, even if the SQL
Server is running in only Windows Authentication Mode. A complex password
protects SQL Server from someone easily getting administrative access to SQL
Server. This also protects the server in the event that an administrator
changes the security authentication mode to Mixed Mode.
Do not use the sa login account in a production environment. Instead, place
each DBA's network user account into a Windows group, create a single SQL
Server login account for the group then add the login account to the
sysadmin fixed server role. "
(http://www.microsoft.com/technet/pr...in/sqlops3.mspx
).
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com|||Thank you for the information.
The book I was reading is Microsoft Press and the authors are Ed Robinson
and Michael James Bond.
I have the SA password complex so no worries there.
I guess I'll leave the xp_cmdshell alone as it seems to be more trouble that
it is worth to remove it.
Should I think about installing URLScan ?
"Dejan Sarka" <dejan_please_reply_to_newsgroups.sarka@.avtenta.si> wrote in
message news:%23BAAU89pFHA.3112@.TK2MSFTNGP12.phx.gbl...
> The sa login account cannot be deleted or renameed, nor it can't be
> revoked any permission.
>
> I don't think MS ever mentioned droping the sa account (as it can't be
> done). Here are recommendations from Operations Guide: "
> The sa account in a production environment should be given a complex
> password, made up of uppercase and lowercase letters, symbols, spaces, and
> numbers. The sa account should have a complex password, even if the SQL
> Server is running in only Windows Authentication Mode. A complex password
> protects SQL Server from someone easily getting administrative access to
> SQL Server. This also protects the server in the event that an
> administrator changes the security authentication mode to Mixed Mode.
> Do not use the sa login account in a production environment. Instead,
> place each DBA's network user account into a Windows group, create a
> single SQL Server login account for the group then add the login account
> to the sysadmin fixed server role. "
> (http://www.microsoft.com/technet/pr...ityLearning.com
>|||> Should I think about installing URLScan ?
Why don't you ask this in some IIS group, with explanation why do you think
you need it?
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com

Friday, February 24, 2012

Cant modify or delete an existing job

Folks, i have rebuilt my old server machine and i've restored the MSDB over the new machine. Now when i try to edit or delete any of the jobs that come from the RESTORE; i get the following error message:

I never setup multiserver administration.
However i can create and delete new jobs.
How do i remove these older jobs.

Howdy!This happened to me once, when a machine was renamed. I think it is as simple as updating the sysjobs table to reflect the new server name (originating_server column). Make sure you have a good backup, before you do this, however.|||sorry: the error message is:
error 14274: Cannot add, update, or delete a job that originated from anMSX server.

Thanx, MCrowley. I would try this when the users are off the machine.

Howdy.|||My experience was the exact same as MCrowley's; I think I went in and hand-edited the jobs in the msdb database (through EM; it was a long time ago). You may need to set the switch to allow updating of system tables, but I don't recall that I had to do that.

Regards,

hmscott

sorry: the error message is:
error 14274: Cannot add, update, or delete a job that originated from anMSX server.

Thanx, MCrowley. I would try this when the users are off the machine.

Howdy.|||i am squared. thanx.

USE MASTER
GO
sp_configure 'allow updates' ,1
GO
RECONFIGURE WITH OVERRIDE
GO
USE MSDB
go
update sysjobs set originating_server='myserver'
GO
USE MASTER
GO
sp_configure 'allow updates' ,0
GO
RECONFIGURE WITH OVERRIDE

--HOWDY!|||Just had the same problem on a rebuilt server - the above script sorted it out.

thanks,
Paul.

Sunday, February 12, 2012

Cant insert and delete

Hi,

Can anyone help me? I am using MSDE 2000 with VS.NET. I can SELECT from the database but i cant insert and delete and update. Below are my code

public static int Add(string tmpSql, string connectionString)

{

oleConn = new OleDbConnection(connectionString);

oleConn.Open();

oleTran = oleConn.BeginTransaction();

try

{

oleCom = new OleDbCommand(tmpSql, oleConn);

oleCom.Transaction = oleTran;

int a =oleCom.ExecuteNonQuery();

return(0);

}

catch

{

oleTran.Rollback();

return(1);

}

finally

{

oleConn.Close();

}

}

my int a give a value of 1 but when i look at the database the data is not inserted? but my primary key of the table did increase by one. what went wrong? is it due to my configuration which dun allow my to insert and update? help. Thank you

Please some1 pls help me or send me any useful link and i will figure out my self thanks..

|||Is it possible that you need to explicitly commit your transaction inside your try block before returning? In the example code on MSDN at the link below the transaction is explicitly committed.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbconnectionclassbegintransactiontopic.asp

Hope this helps,
Vaughn|||oh ya how can i forget that.. thanks alot.. Big Smile