Monday, March 12, 2012
HELP! Database lost ALL Data!
I got a complaint form a customer. No one can log on to the application. I
took a look at the database (SQL Server 2000) it was empty. I never saw such
a sight before. Even when we ship the database brand new, it is seeded with
some metadata entries. But this database was completely blank.
The only way I can think this could conceivably happen is for a DTS package
to start a database transfer, drop and recreate all the tables and then
terminate before it begins copying data. But no one will admit to running
any DTS jobs. One of our techs was on their box today, but he swears he just
ran a batch file to copy some filesystem (not database) files.
Either someone is lying, or maybe there's another reason why this could
happen? If you can explain how this might have happened, you'll get one of
our support techs out of a lot of trouble.
Thanks!
- Joe Geretz -Hi,
By default SQL Server will not audit any activity inside database. In this
scenario you could identify the problem by veryfying scripts ran.
One more way is if your recovery model is FULL or BULK_LOGGED you could use
log explorer to read the trasnaction log file.
See the link for the details on Logexplorer.
www.lumigent.com
FYI, If you have the database in FULL recovery plus if you have full
database backup and all trasnaction log backups you
could recover the database using POINT_IN_TIME recovery.
Thanks
Hari
MCDBA
"Joseph Geretz" <jgeretz@.nospam.com> wrote in message
news:eL2gtr4bEHA.3580@.TK2MSFTNGP11.phx.gbl...
> Anyone ever heard of this?
> I got a complaint form a customer. No one can log on to the application. I
> took a look at the database (SQL Server 2000) it was empty. I never saw
such
> a sight before. Even when we ship the database brand new, it is seeded
with
> some metadata entries. But this database was completely blank.
> The only way I can think this could conceivably happen is for a DTS
package
> to start a database transfer, drop and recreate all the tables and then
> terminate before it begins copying data. But no one will admit to running
> any DTS jobs. One of our techs was on their box today, but he swears he
just
> ran a batch file to copy some filesystem (not database) files.
> Either someone is lying, or maybe there's another reason why this could
> happen? If you can explain how this might have happened, you'll get one of
> our support techs out of a lot of trouble.
> Thanks!
> - Joe Geretz -
>|||I believe I've found the cause for the database erasure and I've documented
this in my posting
Use of (local) in DTS. Dangerous!!!? of 7/25/2004.
If you have any further comments on my situation, I'd be most grateful to
hear them.
Thanks!
- Joe Geretz -
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:uSU2Xt5bEHA.996@.TK2MSFTNGP12.phx.gbl...
> Hi,
> By default SQL Server will not audit any activity inside database. In this
> scenario you could identify the problem by veryfying scripts ran.
> One more way is if your recovery model is FULL or BULK_LOGGED you could
use
> log explorer to read the trasnaction log file.
> See the link for the details on Logexplorer.
> www.lumigent.com
> FYI, If you have the database in FULL recovery plus if you have full
> database backup and all trasnaction log backups you
> could recover the database using POINT_IN_TIME recovery.
> Thanks
> Hari
> MCDBA
>
> "Joseph Geretz" <jgeretz@.nospam.com> wrote in message
> news:eL2gtr4bEHA.3580@.TK2MSFTNGP11.phx.gbl...
I[vbcol=seagreen]
> such
> with
> package
running[vbcol=seagreen]
> just
of[vbcol=seagreen]
>
HELP! Database lost ALL Data!
I got a complaint form a customer. No one can log on to the application. I
took a look at the database (SQL Server 2000) it was empty. I never saw such
a sight before. Even when we ship the database brand new, it is seeded with
some metadata entries. But this database was completely blank.
The only way I can think this could conceivably happen is for a DTS package
to start a database transfer, drop and recreate all the tables and then
terminate before it begins copying data. But no one will admit to running
any DTS jobs. One of our techs was on their box today, but he swears he just
ran a batch file to copy some filesystem (not database) files.
Either someone is lying, or maybe there's another reason why this could
happen? If you can explain how this might have happened, you'll get one of
our support techs out of a lot of trouble.
Thanks!
- Joe Geretz -Hi,
By default SQL Server will not audit any activity inside database. In this
scenario you could identify the problem by veryfying scripts ran.
One more way is if your recovery model is FULL or BULK_LOGGED you could use
log explorer to read the trasnaction log file.
See the link for the details on Logexplorer.
www.lumigent.com
FYI, If you have the database in FULL recovery plus if you have full
database backup and all trasnaction log backups you
could recover the database using POINT_IN_TIME recovery.
Thanks
Hari
MCDBA
"Joseph Geretz" <jgeretz@.nospam.com> wrote in message
news:eL2gtr4bEHA.3580@.TK2MSFTNGP11.phx.gbl...
> Anyone ever heard of this?
> I got a complaint form a customer. No one can log on to the application. I
> took a look at the database (SQL Server 2000) it was empty. I never saw
such
> a sight before. Even when we ship the database brand new, it is seeded
with
> some metadata entries. But this database was completely blank.
> The only way I can think this could conceivably happen is for a DTS
package
> to start a database transfer, drop and recreate all the tables and then
> terminate before it begins copying data. But no one will admit to running
> any DTS jobs. One of our techs was on their box today, but he swears he
just
> ran a batch file to copy some filesystem (not database) files.
> Either someone is lying, or maybe there's another reason why this could
> happen? If you can explain how this might have happened, you'll get one of
> our support techs out of a lot of trouble.
> Thanks!
> - Joe Geretz -
>|||I believe I've found the cause for the database erasure and I've documented
this in my posting
Use of (local) in DTS. Dangerous!!!? of 7/25/2004.
If you have any further comments on my situation, I'd be most grateful to
hear them.
Thanks!
- Joe Geretz -
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:uSU2Xt5bEHA.996@.TK2MSFTNGP12.phx.gbl...
> Hi,
> By default SQL Server will not audit any activity inside database. In this
> scenario you could identify the problem by veryfying scripts ran.
> One more way is if your recovery model is FULL or BULK_LOGGED you could
use
> log explorer to read the trasnaction log file.
> See the link for the details on Logexplorer.
> www.lumigent.com
> FYI, If you have the database in FULL recovery plus if you have full
> database backup and all trasnaction log backups you
> could recover the database using POINT_IN_TIME recovery.
> Thanks
> Hari
> MCDBA
>
> "Joseph Geretz" <jgeretz@.nospam.com> wrote in message
> news:eL2gtr4bEHA.3580@.TK2MSFTNGP11.phx.gbl...
> > Anyone ever heard of this?
> >
> > I got a complaint form a customer. No one can log on to the application.
I
> > took a look at the database (SQL Server 2000) it was empty. I never saw
> such
> > a sight before. Even when we ship the database brand new, it is seeded
> with
> > some metadata entries. But this database was completely blank.
> >
> > The only way I can think this could conceivably happen is for a DTS
> package
> > to start a database transfer, drop and recreate all the tables and then
> > terminate before it begins copying data. But no one will admit to
running
> > any DTS jobs. One of our techs was on their box today, but he swears he
> just
> > ran a batch file to copy some filesystem (not database) files.
> >
> > Either someone is lying, or maybe there's another reason why this could
> > happen? If you can explain how this might have happened, you'll get one
of
> > our support techs out of a lot of trouble.
> >
> > Thanks!
> >
> > - Joe Geretz -
> >
> >
>
HELP! Database lost ALL Data!
I got a complaint form a customer. No one can log on to the application. I
took a look at the database (SQL Server 2000) it was empty. I never saw such
a sight before. Even when we ship the database brand new, it is seeded with
some metadata entries. But this database was completely blank.
The only way I can think this could conceivably happen is for a DTS package
to start a database transfer, drop and recreate all the tables and then
terminate before it begins copying data. But no one will admit to running
any DTS jobs. One of our techs was on their box today, but he swears he just
ran a batch file to copy some filesystem (not database) files.
Either someone is lying, or maybe there's another reason why this could
happen? If you can explain how this might have happened, you'll get one of
our support techs out of a lot of trouble.
Thanks!
- Joe Geretz -
Hi,
By default SQL Server will not audit any activity inside database. In this
scenario you could identify the problem by veryfying scripts ran.
One more way is if your recovery model is FULL or BULK_LOGGED you could use
log explorer to read the trasnaction log file.
See the link for the details on Logexplorer.
www.lumigent.com
FYI, If you have the database in FULL recovery plus if you have full
database backup and all trasnaction log backups you
could recover the database using POINT_IN_TIME recovery.
Thanks
Hari
MCDBA
"Joseph Geretz" <jgeretz@.nospam.com> wrote in message
news:eL2gtr4bEHA.3580@.TK2MSFTNGP11.phx.gbl...
> Anyone ever heard of this?
> I got a complaint form a customer. No one can log on to the application. I
> took a look at the database (SQL Server 2000) it was empty. I never saw
such
> a sight before. Even when we ship the database brand new, it is seeded
with
> some metadata entries. But this database was completely blank.
> The only way I can think this could conceivably happen is for a DTS
package
> to start a database transfer, drop and recreate all the tables and then
> terminate before it begins copying data. But no one will admit to running
> any DTS jobs. One of our techs was on their box today, but he swears he
just
> ran a batch file to copy some filesystem (not database) files.
> Either someone is lying, or maybe there's another reason why this could
> happen? If you can explain how this might have happened, you'll get one of
> our support techs out of a lot of trouble.
> Thanks!
> - Joe Geretz -
>
|||I believe I've found the cause for the database erasure and I've documented
this in my posting
Use of (local) in DTS. Dangerous!!!? of 7/25/2004.
If you have any further comments on my situation, I'd be most grateful to
hear them.
Thanks!
- Joe Geretz -
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:uSU2Xt5bEHA.996@.TK2MSFTNGP12.phx.gbl...
> Hi,
> By default SQL Server will not audit any activity inside database. In this
> scenario you could identify the problem by veryfying scripts ran.
> One more way is if your recovery model is FULL or BULK_LOGGED you could
use[vbcol=seagreen]
> log explorer to read the trasnaction log file.
> See the link for the details on Logexplorer.
> www.lumigent.com
> FYI, If you have the database in FULL recovery plus if you have full
> database backup and all trasnaction log backups you
> could recover the database using POINT_IN_TIME recovery.
> Thanks
> Hari
> MCDBA
>
> "Joseph Geretz" <jgeretz@.nospam.com> wrote in message
> news:eL2gtr4bEHA.3580@.TK2MSFTNGP11.phx.gbl...
I[vbcol=seagreen]
> such
> with
> package
running[vbcol=seagreen]
> just
of
>
Friday, March 9, 2012
Help! C# - Forms - Datasource
My god.
All I want to do is post the contents of a web form to a database sql express 2005 or access using C#. Why can I find nothing for this very simple process online?
Can you tell I am totally frustrated?
So lets say i have a few text fields and I want to click submit and have that entered into a table. I use C# for code behind. So I can do basic C# programming and I can to webforms with visual web developer 2005 dragging and dropping for textboxs and a button to the aspx page. But then the mystery begins for me. How the hell do I simple post that form data to the table. I understand connection string basics. I aslo can design and create tables.
But tying this all together is becoming a problem. I don't want to use gridview formview detailview or any of that canned UI stuff. I also don't understand VB and when I see VB examples they only cloud my already cloud ASP.NET world.
Please help by posting examples, and maybe some links or books to add to my newbish collection.
Thanks,
Frank
A very simplified example. Hope that will help
<form id="form1" runat="server"> <div> <asp:TextBox ID="txtInput" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtInput" ErrorMessage="Value needed"></asp:RequiredFieldValidator> <br /> <br /> <asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="Save" /></div> </form>
and below is the button click event:
string cnStr =""//your connection string herestring valueToSave = txtInput.Text.Trim();string qry =""// your insert query here SqlConnection cn =new SqlConnection(cnStr);cn.Open();SqlCommand cm =new SqlCommand(qry, cn);int i = cm.ExecuteNonQuery();|||
Ok, this looks like what I am looking for but I have two other questions...but first here is my code:
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><asp:ButtonID="Button1"runat="server"OnClick="Button1_Click"Text="Button"/>
<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label>string cnStr ="";//connection string stuff here
string name = TextBox1.Text.Trim();
string qry ="insert into [name] value [name]";//insert statement here
SqlConnection cn =new SqlConnection(cnStr);
cn.Open();
SqlCommand cm =new SqlCommand(qry, cn);
int i = cm.ExecuteNonQuery();
when generating a connectionstring I see this in the wizard:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True
I made a simple table called 'name' with a text field called 'name' (that sql statement up there might be incorrect as well.
My question is how do I properly format the connection string if it is in app_Data for my project called 'form'?
Second question is my SQL statement correct for inserting a value into 'name'?
Thanks,
Frank
|||
Answer to your second question is no, it will be something like - "insert into name value " ' " + name + " ' ".
And i did not get your first question. If you can provide a little more detail it will be helpful
Sunday, February 19, 2012
Help with update forms
Still very new to asp/sql but trying to learn stuff as I go along.
I'm trying to create an update form where it pulls in an existing record, I
can update it, then submit the changes.
The problem i'm having is when i click to update the record I get this error
message
Cannot update identity column 'id'
In the update form, the ID column is hidden, so i'm not trying to change
that.
How do I get around it?
Thanks for your help.
RichHow are you performing the update? Can you post the actual SQL Statement?
You can't update an IDENTITY column.
David Portas
SQL Server MVP
--|||Hi David
Here's the statement - it was done through dreamweaver, so the code probably
isn't as neat as it should be.
' *** Update Record: set variables
If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <>
"") Then
MM_editConnection = MM_musicone_STRING
MM_editTable = "dbo.m1_web_content"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "articleupdated.asp"
MM_fieldsStr =
" id|value|Publish_Date|value|Section|valu
e|Section_Type|value|Title|value|In
tro|value|Full_Text|value|LiveDate|value
|HyperLink|value|ImageSrc|value|Live
|value"
MM_columnsStr =
" id|none,none,NULL|Publish_Date|',none,NU
LL|Section|',none,''|Section_Type|'
,none,''|Title|',none,''|Intro|',none,''
|Full_Text|',none,''|LiveDate|',none
,NULL|HyperLink|',none,''|ImageSrc|',non
e,''|Live|none,1,0"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And
Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "")
Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " &
MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
Any advice would be appreciated!
Thanks
Rich
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:zOKdnaCOHNU1EQ7fRVn-gA@.giganews.com...
> How are you performing the update? Can you post the actual SQL Statement?
> You can't update an IDENTITY column.
> --
> David Portas
> SQL Server MVP
> --
>|||It looks like your UPDATE statement is attempting to update every column (in
the FOR loop). Aside from the specific problem you are having this seems
like a very error-prone and inefficient implementation. In general, avoid
generating SQL dynamically in code. Put your data access code in stored
procs and pass parameters from ASP to the proc. I'm not an ASP expert but
here's someone who is and has some tips and examples of good practices in
ASP:
http://www.aspfaq.com/show.asp?id=2201
http://www.aspfaq.com/show.asp?id=2424
David Portas
SQL Server MVP
--|||Thanks David, some really useful info that - much appreciated.
Richard
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:vaqdnR2tCdwjAg7fRVn-gA@.giganews.com...
> It looks like your UPDATE statement is attempting to update every column
> (in the FOR loop). Aside from the specific problem you are having this
> seems like a very error-prone and inefficient implementation. In general,
> avoid generating SQL dynamically in code. Put your data access code in
> stored procs and pass parameters from ASP to the proc. I'm not an ASP
> expert but here's someone who is and has some tips and examples of good
> practices in ASP:
> http://www.aspfaq.com/show.asp?id=2201
> http://www.aspfaq.com/show.asp?id=2424
> --
> David Portas
> SQL Server MVP
> --
>