Saturday, March 31, 2012
Table...StyleSheet...CellPadding = 0, I cant do it :(
Why does .NET default to CellPadding and CellSpacing of 2?!
How on earth can I set them to all be 0.
I tried adding a table style to the style sheet, but cellpadding and cellspacing do not come up in intelisense :(
Any ideas?
WokaWhy is that VS.NET's fault? :rolleyes:
For cellpadding:
padding: 0 0 0 0;
For cellspacing, it's best to leave it in the table tag, I haven't seen a 'universal' solution to cellspacing in CSS.
That's what I would have thought.
In my CSS file I have:
TABLE
{
border: solid 0px Red;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
TR
{
border: solid 0px Blue;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
TD
{
border: solid 0px Lime;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
Yet, as you can see from the attached pic, the images do not sit next to each other.
I am forced to add cellpadding and cellspacing to the table directly in my ASPX page (code in front).
The border props are only there for testing. The tables and cells etc do take on all the properties from my style sheet, apart from the cellpaddingthing etc :(
WOka
You should be using floating div's for a menu control anway ;)
Anyway, those 'cells' could be easily duplicated with span tags with a style padding of 10px.
<span style="padding:5px;">Home</span><span style="padding:5px;">About Us</span><span style="padding:5px;">Products</span>
Wednesday, March 28, 2012
TableAdapters and db transactions (begin, comit,roleback....)
Hello
Doing some webapp. in ASP.NET and using som of tutorials from this site
http://www.asp.net/learn/dataaccess/default.aspx?tabid=63 . I havent seen
anything aboat transactions. Is it TableAdapters that runs the show ?
Or if not, where to implement it, becouse whan you to insert data you use a GridView or DetailsView
point to some methode yuo allready made in TableAdapter and thats it. Or am I missing somthing?
Thanks
Its Connection object which handles transactions for you.
SqlTransaction tran = Conn.BeginTransaction();
If you are using DataAdaptor, get the command object,
SqlCommand cmdDelete = DataAdaptor.GetDeleteCommand();
SqlCommand cmdInsert = DataAdaptor.GetInsertCommand();
SqlCommand cmdUpdate = DataAdaptor.GetUpdateCommand();
cmdDelete.Transaction = tran;
cmdInsert.Transaction = tran;
cmdUpdate.Transaction = tran;
Assign this tranaction object to a SQLCommand, use
tran.rollback, to rollbak transactions
tran.commit, to commit transactions
Hope this answers your question.
I think I've got it!!! :-)
ClientTableAdapter clientAdapt =newClientTableAdapter();
SqlConnection myConnection =newSqlConnection("server=(local)\\SQLExpress;Integrated Security=SSPI;database=Novabaza");SqlCommand myCommand =newSqlCommand();SqlTransaction myTrans;// Open the connection.
myConnection.Open();
// Assign the connection property.myCommand.Connection = myConnection;
// Begin the transaction.myTrans = myConnection.BeginTransaction();
// Assign transaction object for a pending local transactionmyCommand.Transaction = myTrans;
try{
// Create a SavepointclientAdapt.InsertClientdata(TextBoxName.Text, TextBoxSurname.Text,Convert.ToInt32(TextBoxTelnr.Text));myTrans.Commit();Response.Write(
" Records are written to the database!");}
catch (Exception ex)
{
myTrans.Rollback();
Response.Write("Record is not written to the database!");throw ex;
}
finally{
myConnection.Close();
}
InsertClientdata() is a query procedure I've made within (Client)tableadapter.
Now I'm goign to try something about using several adapters and creating some "SavePoints" for RollBack
Thanks a lot
tables
I have created a fully functioning website but there is one problem - it comtains 2 tables on the default page which have a gap!
I have entered padding="opx" border="0px" and it hasn't worked??
there is no <br /> between the tables or a nbsp;
help?!!
rach
Can you provide a link to your website?
Try put
cellspacing="0"cellpadding="0"border="0" into you two tables
For CSS, set the padding to 0 and the MARGIN to 0.
it's ok I have done it now! it was really basic! d'oh
Rach
Tuesday, March 13, 2012
Targeting a database path that is outside of the current project?
Well, good thing that the forum stated "No question too simple" because I'm sure this is uber basic...
I have a working Default.aspx page that accesses a database (hsDatabase.mdf) within the App_Data folder. Just the basic ASP website structure automatically made by Visual Web Developer 2005 Express Edition.
The page works fine on the local computer.
The problem is, when I put it up on my server on the web, the server requires all databases to be put in a specific "database" folder which is up a level from the html folder where I put my ASP and HTML files. That is, it's outside of the project folder.
And try as I might, I can't seem to get the Default.aspx page to connect with database when it's not residing in a folder called "App_Data" which is at the same level as the ASP file.
I assume that the key lies in how I write the connectionstring in the web.config file?
This is the connectionstring that works on my computer:
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\hsDatabase.mdf;Integrated Security=True;User Instance=True"
But instead of|DataDirectory|\hsDatabase.mdf, I wish I could just put write a hardcoded address like www.mySite.com/database/hsDatabase.mdf.
Or at least a relative path that worked like../../database/hsDatabase.mdf
How can I connect to a database that's outside of my project folder, or anywhere on the web for that matter?
Thanks everyone!
Hopefully this helps -
Imports System.Data.SqlClientImports System.IOImports System.Web.ConfigurationPartialClass DefaultInherits System.Web.UI.PageProtected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadDim bldrAs New SqlConnectionStringBuilder(WebConfigurationManager.ConnectionStrings("connectionStringName").ConnectionString) bldr.AttachDBFilename = Path.GetFullPath("/otherDir/hsDatabase.mdf")' output modified connection string Response.Write(bldr.ConnectionString &"<hr/>")End SubEnd ClassWell, that's a bit more complicated that I thought it would be! Definitely a change from the old ASP style of doing it.
The outputted modified connection string (bldr.ConnectionString),should I be putting that result into my Default.aspx page or my web.config page? And how do I pass that variable from this .aspx.vb page into the correct page?
BTW... the connection code for the Default.aspx page is: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
while the web.config page is: <connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\hsDatabase.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Thank you so much again!
Hi robchis,
My suggestion could be wrong,so please correct me if you find any mistakes within my suggestion.Based on my understanding and experience,I think of course you can access the database which is outside of your website root directory. I used to access a sql database which is hosted by another server machine from my website and it works fine. The point is, make sure that the data server has sql-server serverside installed with service correctlly configured and started, then within you website, you can click the "configure Data Source" from you sqldatasource control and input the right sql-server server name and choose the right database.After that you will be able to access the database in your site.
For more and detailed information, please refer to:
http://msdn2.microsoft.com/en-us/library/ms178361.aspx
http://dotnetjunkies.com/QuickStartv20/aspnet/doc/data/databases.aspx