Showing posts with label single. Show all posts
Showing posts with label single. Show all posts

Friday, March 30, 2012

putting multiple xml files data into database in a single transaction

Super AngryFirst of all i do not know whether this is the right form to ask the question

Let me describe the scenario iam using

Iam generating xml files at a particular place and sending them to a server

xml1|------->dataset1---------->adapter1.update(dataset1)

xml2|-------->dataset2---------->adapter2.update(dataset2)

xml3|-------->dataset3---------->adapter3.update(dataset3)

all thethree updates should happen in onlyone transaction if any one of the update fails then the transaction should rollback

can anyone tell me a way to do it

i am desperately in search of any ways to do it can anybody help pleaseSad

If the 3 SqlDataAdapters are using the same connection, maybe you can try to embed the updates in a single transaction opened on the connection:

using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["myConn"].ToString()))
{

conn.open;

//build your SqlDataAdapters on the same conneciton

SqlTransaction st;
st=conn.BeginTransaction("tran1");
adapter1.update(dataset1);

adapter2.update(dataset2);

adapter3.update(dataset3);

st.Commit();
}

|||

ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized

This is the error iam getting bcoz iam using the command builder to update the table using dataset cant we use command builder and transaction at the same time

or we should use only sqlcommand to the method

can anybody tell me the solution cant we use transaction and adapter and commandbuilder at the same time

[:'(]

Putting Multiple Field data in a report table cell

I'm using report designer and Visual Studio .net 2003. I have a table in the report and would like to put multiple field values in a single cell. Something along the lines of this in the cell: =Fields!Phone.Value, Fields!.Fax.Value.

I don't know how to seperate the values to get them to work in the same table cell. I've tried commas, semi colons, spaces, parens.

How would I do this?=Fields!Phone.Value & " " & Fields!Fax.Value should work.
|||Great that works!

One other question, if I put a symbol (comma, semicolon) in the between the ampersands, how do I get it to leave the cell blank if there is nothing stored in the fields?

For example, say I have =Fields!Phone.Value & ", " & Fields!Fax.Value in the cell but when there is no values for those fields the cell is ", ".|||=Fields!Phone.Value & ISNULL(Fields!Fax.Value,"",",") & Fields!Fax.Value should work?
Otherwise you can try using IIF.
|||I couldn't use IsNull because it says it is not decleared. I can use IIF, so the correct code is =Fields!Phone.Value & IIF(Fields!Fax.Value=nothing,"",",") & Fields!Fax.Value

Thanks for your help.

sql

Wednesday, March 28, 2012

Putting encypted values in a database

hi guys,

Could any one tell me whats the best way to put encypted data into a table.
i have a textfield that a single integer is entered into it. It is then encrypted using DES encrption algorithim.It converts the value to byte(Convert2ByteArray method) I pass the data to a stored procedure which converts it to char before inserting it into the table. when i checked the database all it entered was System.Byte[]. Does anyone know where im goin wrong?

Mairtin

The problem lies because the .ToString method of your byte [] returns "System.Byte[]". You will need to manually convert this over to a string before placing this into your Stored Procedure.

System.Converthas a couple methods to help you with this.

byte [] encryptedBytes = GetEncryptedBytes( unencryptedData );
string encryptedString = System.Convert.ToBase64String( encryptedBytes );

To unencrypt the string you must go the other way.

byte encryptedBytes = System.Convert.FromBase64String( encryptedString );
unencryptedData = GetDecryptedString( encryptedBytes );

bill
|||

hey billrob,

i tried that out.
I dont know if it has done what is suppose to! I wrote the encrypted value out to a textfile aswell to see the difference.

in the database the value was Mw==
in the textfile the value looked like ??Xq/ ê à?*?a?]T¥ù?±@.àcl<tTàFE/.(without System.covert used on it )

Somehow i think i may be going wrong,

|||How were you viewing it in the Database? The binary data looks (from textfile) looks like valid data, post some of your code, but remove your Vector and key from the post.

ToBase64 and FromBase64 are inverse operations. If you take your binary blob, base64 it, then turn it back into binary, you will have the same thing.

How large did you make your text column in the database that stores this information.

bill

FYI, the Base64String stuff is very similiar to how .NET processes the ViewState.

Putting a DB into Single User Mode...

How do I do this when that option is grayed out? Also,
how does the single vs. the other mode impact persons
using the db?
Thanks in advancePatrick,
You can also use the command:
ALTER DATABASE databasename SINGLE_USER
Why is the option grayed out? Do you have sufficient rights to issue the
command on this database? You must be the db_owner or in the system roles
of sysadmin or dbcreator.
Russell Fields
"Patrick Ross" <yourmcse@.msn.com> wrote in message
news:1274901c3f62b$c9afe3c0$a601280a@.phx.gbl...
> How do I do this when that option is grayed out? Also,
> how does the single vs. the other mode impact persons
> using the db?
> Thanks in advancesql

Putting a DB into Single User Mode...

How do I do this when that option is grayed out? Also,
how does the single vs. the other mode impact persons
using the db?
Thanks in advancePatrick,
You can also use the command:
ALTER DATABASE databasename SINGLE_USER
Why is the option grayed out? Do you have sufficient rights to issue the
command on this database? You must be the db_owner or in the system roles
of sysadmin or dbcreator.
Russell Fields
"Patrick Ross" <yourmcse@.msn.com> wrote in message
news:1274901c3f62b$c9afe3c0$a601280a@.phx
.gbl...
> How do I do this when that option is grayed out? Also,
> how does the single vs. the other mode impact persons
> using the db?
> Thanks in advance

Tuesday, March 20, 2012

pulling single lines from a DB

hi im making a page where i want a single line at a time to be pulled from my MS Database, basically at the moment i have a list of questions, but the page is displaying all the questions from my database, i only want it to pull out 1 and then if the user clicks the true button then it goes to another page and displays another question?

Any ideas

Regards,

JoeHi Joe,

Are you want to retrieve any 1 question from DB randomly?
FYI:http://www.datawebcontrols.com/faqs/Data/ReturningDataInRandomOrder.shtml

Regards,

Monday, March 12, 2012

Pull replication errors...

Hi,
the idea is to setup an offsite backup of our single sql server, have
created a publication on the MASTER server, and pulled it to the offsite
server using FTP, downloaded snapshot, replicated transactions, all appeared
to work, generated schema, but the frontend database app didnt run, loads of
various errors showing up.
decided to restore the database from disk to the backup server, to check the
app is working fine, which it now is, so all i need to do is replicated the
changes in the tables on the master server to the offsite server, only needs
to be one-way, the offsite is only for backup read only...changed the
publication to tables only, re-created snapshot and now get errors saying...
Cannot update identity column. The step failed
help please on solution or other ways to achive this.
comment the identity column update in the update proc.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Matt" <mattnj@.hotmail.com> wrote in message
news:d9tqpf$gkn$1@.news.freedom2surf.net...
> Hi,
> the idea is to setup an offsite backup of our single sql server, have
> created a publication on the MASTER server, and pulled it to the offsite
> server using FTP, downloaded snapshot, replicated transactions, all
> appeared to work, generated schema, but the frontend database app didnt
> run, loads of various errors showing up.
> decided to restore the database from disk to the backup server, to check
> the app is working fine, which it now is, so all i need to do is
> replicated the changes in the tables on the master server to the offsite
> server, only needs to be one-way, the offsite is only for backup read
> only...changed the publication to tables only, re-created snapshot and
> now get errors saying...
> Cannot update identity column. The step failed
> help please on solution or other ways to achive this.
>