Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Saturday, March 31, 2012

Table Rows

Hello,
I have dynamically created a table in ASP.NET using tbl.rows.add(tr)
method where 'tbl' is a System.Web.UI.WebControls.Table. and tr is a
TableRows object.
Any ideas why I can't then itterate through the table object and reference
each of the rows using:
Dim tb as tablesRow
For Each tr In tbl.Rows
xx = tr.Cells(1).Text
Next
There appears to be no rows in the table ie. tbl.tablerows.count = 0
TIA
TimDim t as new table
Page.Controls.Add(t)
Dim r As TableRow
Dim c As TableCell
For i As Int32 = 0 To 5
r = New TableRow
c = New TableCell
c.Text = i.ToString
r.Cells.Add(c)
t.Rows.Add(r)
Next
For Each r In t.Rows
Response.Write("<BR>Cell Value = " & r.Cells(0).Text)
Next
"Tim" <timbryant@.smoothit.co.uk> wrote in message
news:OUr4bISvFHA.2064@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have dynamically created a table in ASP.NET using tbl.rows.add(tr)
> method where 'tbl' is a System.Web.UI.WebControls.Table. and tr is a
> TableRows object.
> Any ideas why I can't then itterate through the table object and reference
> each of the rows using:
> Dim tb as tablesRow
> For Each tr In tbl.Rows
> xx = tr.Cells(1).Text
> Next
> There appears to be no rows in the table ie. tbl.tablerows.count = 0
> TIA
> Tim
>
>
Tim,
If you are trying to access the rows on postback, note, that you have to
re-create dynamucally created objects in the code.
Eliyahu
"Tim" <timbryant@.smoothit.co.uk> wrote in message
news:OUr4bISvFHA.2064@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have dynamically created a table in ASP.NET using tbl.rows.add(tr)
> method where 'tbl' is a System.Web.UI.WebControls.Table. and tr is a
> TableRows object.
> Any ideas why I can't then itterate through the table object and reference
> each of the rows using:
> Dim tb as tablesRow
> For Each tr In tbl.Rows
> xx = tr.Cells(1).Text
> Next
> There appears to be no rows in the table ie. tbl.tablerows.count = 0
> TIA
> Tim
>
>

TableAdapter Insert (Primary Key)

Hi

I have just started to learn ASP.Net. However I have some experience with ASP.

Anyway I have created a asp-form which should create a new entry in the database after you have clicked the submit button.

I created a tableadapter and following simple code:
tbUsersTableAdapter topAdapter=new tbUsersTableAdapter();
topAdapter.InsertUser(DateTime.Now, DateTime.Now, DateTime.Now,true,false, txtNickname.Text, 2, txtEMail.Text, txtPassword.Text,"");

Here is the SQl Command without the primary key:
INSERTINTO[tbUsers] ([CDate], [MDate], [ADate], [Active], [Activated],[Nickname], [Role],Email, [Password],[IP])VALUES (@dotnet.itags.org.CDate, @dotnet.itags.org.MDate, @dotnet.itags.org.ADate, @dotnet.itags.org.Active, @dotnet.itags.org.Activated, @dotnet.itags.org.Nickname, @dotnet.itags.org.Role, @dotnet.itags.org.eMail, @dotnet.itags.org.Password, @dotnet.itags.org.IP)

This works fine as long as I put the ID (Primary Key) into the Insert command. But I don't know how I can find out the next avaiable primary key. I have thought it would be automatically incremented. Anyway I went to the properties of the tableadapter and there was a property which I switched on for my primary key field "AutoIncrement". However it still doesn't work.
Before I used to work with MS Access and OleDB Connection. There I just skipped the Primary Key Value and it has been created automatically. Here I get an error message that the primary key can't be null.

I hope somebody could help me with that or has an idea what I'm doing wrong.

thx

Hi

I searched and tried out a lot of things. Finally I found the problem today. I had to open the table with the Server Explorer. Actually I set my ID field to Primary Key but I forgot to set the Identity Column. After I set the Identity Column to my ID field it worked... great;-)))) Now I can just add a new record with skipping the Primary Key and it will be generated automatically.


thx all

Wednesday, March 28, 2012

TableAdapters Created in Dataset (XSD) Issues

Hi,
I've been trying to work with the XSDs and ran into a few road blocks.
1. Stored procedures that uses temp tables, i.e. #TempTable. The
wizard complains that #TempTable is an invalid object. What gives?
2. How do you programatically change the connection string at runtime
when using these TableAdapters via databinding in the IDE GUI?
Thanks,
Nick HustakNick,
Is the stored procedure creating the temp table itself, as opposed to
using a temp table that is created on the same connection by another
procedure?
Also, the connection string handling within 2005 for datasets (XSD) is
pretty weak in my opinion. If you're using the dataset within your
application, then it can use the application or web config file to
store the string. But if you're using a common dataset in a class
library then it uses the connection string from the sql server you have
registered in your IDE and stores it *programmatically* within the
settings designer code. It's because it is a class library and so will
use the configuration from the parent application.
The only way that I know of to override this is to change the
InitConnection method within the dataset designer code to use the
application config connection string from the parent application. This
works, but the obvious problem is that if you then need to change
anything with the adapter from the designer, it will overwrite this
code.
So I guess what you (and I) have to do is wait until right before the
application is to be deployed, and change the InitConnection methods to
use the configuration file settings. This, in my opinion, is not an
acceptable solution, but I'm not sure how else they could implement the
functionality.
Thanks,
Gary
On 27 Jun 2006 06:42:41 -0700, "Gary" <ggalehouse@.neo.rr.com> wrote:

>Nick,
>Is the stored procedure creating the temp table itself, as opposed to
>using a temp table that is created on the same connection by another
>procedure?
>Also, the connection string handling within 2005 for datasets (XSD) is
>pretty weak in my opinion. If you're using the dataset within your
>application, then it can use the application or web config file to
>store the string. But if you're using a common dataset in a class
>library then it uses the connection string from the sql server you have
>registered in your IDE and stores it *programmatically* within the
>settings designer code. It's because it is a class library and so will
>use the configuration from the parent application.
>The only way that I know of to override this is to change the
>InitConnection method within the dataset designer code to use the
>application config connection string from the parent application. This
>works, but the obvious problem is that if you then need to change
>anything with the adapter from the designer, it will overwrite this
>code.
>So I guess what you (and I) have to do is wait until right before the
>application is to be deployed, and change the InitConnection methods to
>use the configuration file settings. This, in my opinion, is not an
>acceptable solution, but I'm not sure how else they could implement the
>functionality.
>Thanks,
>Gary
Gary,
First, thanks for a well 'typed (spoken)' reply. My stored procs use
temp tables for intermediate calcs and things ala CREATE TABLE
#Temp...
I've since seen from another thread that MS KNOWS about this and did
nothing about it. It would appear you can still use the proc in a
dataset, but forget getting a schema in the IDE GUI - it won't read
it. Kind of silly IMHO.
And unfortunately you have confirmed my fear - they let this out the
door without serious consideration for how it works. Why in the world
they would not provide an easy way to override the connection strings
to datasets is beyond me. Wow they dropped the ball on the designer
- I'm a bit suprised seeing as they grabbed Anders from Delphi, which
has excellent designer support for databases work.
Oh well - thanks for the detailed explanation. I really am not happy
with having to remember to swap around the init string in the web
config. I toyed around with trying to manipulate it on the fly, but
it would seem it's completely locked out from programmatic
modification. That would have solved a lot of these issues.
I wonder if DLINQ is going to have the same silly issues. So
close..but these are damn near brick walls. I have zero urge to hand
code all my table objects - such a waste of time.
Thanks again,
Nick

TableAdapters Created in Dataset (XSD) Issues

Hi,
I've been trying to work with the XSDs and ran into a few road blocks.

1. Stored procedures that uses temp tables, i.e. #TempTable. The
wizard complains that #TempTable is an invalid object. What gives?

2. How do you programatically change the connection string at runtime
when using these TableAdapters via databinding in the IDE GUI?

Thanks,
Nick HustakNick,

Is the stored procedure creating the temp table itself, as opposed to
using a temp table that is created on the same connection by another
procedure?

Also, the connection string handling within 2005 for datasets (XSD) is
pretty weak in my opinion. If you're using the dataset within your
application, then it can use the application or web config file to
store the string. But if you're using a common dataset in a class
library then it uses the connection string from the sql server you have
registered in your IDE and stores it *programmatically* within the
settings designer code. It's because it is a class library and so will
use the configuration from the parent application.

The only way that I know of to override this is to change the
InitConnection method within the dataset designer code to use the
application config connection string from the parent application. This
works, but the obvious problem is that if you then need to change
anything with the adapter from the designer, it will overwrite this
code.

So I guess what you (and I) have to do is wait until right before the
application is to be deployed, and change the InitConnection methods to
use the configuration file settings. This, in my opinion, is not an
acceptable solution, but I'm not sure how else they could implement the
functionality.

Thanks,
Gary
On 27 Jun 2006 06:42:41 -0700, "Gary" <ggalehouse@.neo.rr.com> wrote:

>Nick,
>Is the stored procedure creating the temp table itself, as opposed to
>using a temp table that is created on the same connection by another
>procedure?
>Also, the connection string handling within 2005 for datasets (XSD) is
>pretty weak in my opinion. If you're using the dataset within your
>application, then it can use the application or web config file to
>store the string. But if you're using a common dataset in a class
>library then it uses the connection string from the sql server you have
>registered in your IDE and stores it *programmatically* within the
>settings designer code. It's because it is a class library and so will
>use the configuration from the parent application.
>The only way that I know of to override this is to change the
>InitConnection method within the dataset designer code to use the
>application config connection string from the parent application. This
>works, but the obvious problem is that if you then need to change
>anything with the adapter from the designer, it will overwrite this
>code.
>So I guess what you (and I) have to do is wait until right before the
>application is to be deployed, and change the InitConnection methods to
>use the configuration file settings. This, in my opinion, is not an
>acceptable solution, but I'm not sure how else they could implement the
>functionality.
>Thanks,
>Gary

Gary,
First, thanks for a well 'typed (spoken)' reply. My stored procs use
temp tables for intermediate calcs and things ala CREATE TABLE
#Temp...

I've since seen from another thread that MS KNOWS about this and did
nothing about it. It would appear you can still use the proc in a
dataset, but forget getting a schema in the IDE GUI - it won't read
it. Kind of silly IMHO.

And unfortunately you have confirmed my fear - they let this out the
door without serious consideration for how it works. Why in the world
they would not provide an easy way to override the connection strings
to datasets is beyond me. Wow they dropped the ball on the designer
- I'm a bit suprised seeing as they grabbed Anders from Delphi, which
has excellent designer support for databases work.

Oh well - thanks for the detailed explanation. I really am not happy
with having to remember to swap around the init string in the web
config. I toyed around with trying to manipulate it on the fly, but
it would seem it's completely locked out from programmatic
modification. That would have solved a lot of these issues.

I wonder if DLINQ is going to have the same silly issues. So
close..but these are damn near brick walls. I have zero urge to hand
code all my table objects - such a waste of time.

Thanks again,
Nick

TableAdapters using values

I have created a data access layer, have a datset with several tables. In VB I would like to access a the value of a particular cell, put that value into a variable. I am unsure how to do this. So far I have,

1Imports DataSet1TableAdapters2~~~~~~34Dim testID = Request("tid")56Dim levelAs Integer = 07Dim testsTableAdapterAs New TestsTableAdapter89level = testsTableAdapter.GetTestsByTestID(testID).Rows(0).Table.Columns(1)10

I know that this is incorrect, however I wish to get the value held in row 1 column 2. Any help would be much appreciated.

Hi,

Based on my understanding, you want to get the value held in particular cell by DataAdapter. If I have misunderstood you, please feel free to tell me, thanks.

 
Dim constrAs String =""'your connection stringDim connectionAs SqlConnection =New SqlConnection(constr)Dim sqlselAs String ="select * from test"Dim sdaAs SqlDataAdapter =New SqlDataAdapter(sqlsel, connection)Dim dsAs DataSet =New DataSet() sda.Fill(ds,"table")Dim levelAs Integer = ds.Tables("table").Rows(1)(2)
 Hope this can help you.

Try this

SqlConnection conn= new SqlConnection("YOUR CONNECTION STRING")
sql = "select * from TableName"
SqlDataAdapter ad = new SqlDataAdapter(sql, conn)
DataSet DS = new DataSet()

ad.Fill(DS,"TableName") // OR ad.Fill(DS.Tables(0))

Dim lvl As Integer
lvl = (int) DS.Table(0).Rows(1)


thanks for replying.

I was hoping to do it without setting a connection string or inputting SQL into the code. I want the dataset in my DAL to take care of this. Is there any way for the tableadapter to populate a new dataSet?


Please refer to this thread below

http://forums.asp.net/p/1187777/2031770.aspx#2031770

This might give you an idea

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

Thursday, March 22, 2012

Taking your database driven aspx website online.

I have created an ecommerce site using aspx and sql on my local machineat home. And it's now time to take it online and put it on ourserver. Although this is the first site ive ever created usingaspx and sql server. Does anyone know any good tutorials or FAQor anything that would assist me in getting this online... It's all newto me so any help would be greatly appreciated.
Thanx
you need a hoster that supports Asp.Net AND SQL Server.
they will have specifics on how to connect to the the SQL server
You will upload all the .aspx files ( and the directories ) and then upload your .dll's to the "bin" directory
you need to tell some hosters that you are running a .Net site so that they can make your directory an application
HTH


Hello,
What you need now is to find a host then to deploy your application. Let me help you in that
1) one you have hoster, you can access your site using FTP
2) After login to FTP upload your aspx pages to wwwroot of the server
3) Upload the /bin folder to the server also to be like that wwwroot/bin
4) You should access the MSSQL and create database in a control panelthat the hoster will give you the information on how to log in and use
Finally, if u need a great host, i can recommendserverdivision.com, they are oen of the best in .NET technology
HTH
regards

Tuesday, March 13, 2012

targetSchema - Netscape Buttons wont work

I am creating a new web site and this one is for all browsers.

The targetSchema is Navigator 4.0.

I have created a button and placed some code behind, something I have done a thousand times.

Why then won't the code work in this targetSchema when the button is clicked?

Thanks,

Zathnevermind, I had some text boxes on a control on that form and the button was trying to validate them... DOH

td tag generating faulty code

I have created a user control using asp:table control. The control generates
a single column menu controls with 5 rows. each row is supposed to have a
image in link tag. The problem is that ASP.Net framework generates closing
"td" tags on new line. This causes to show extra white pixels at the bottom
of each image. This is because of a known bug in "IE" where it has issues
with closing "td" tag on new line.
Question .... is there a way to control the HTML tags generated by ASP.Net
controls so that I can get the UI the way I want it?
Thanks
Naveen K Kohli
http://www.netomatix.comYou would have to override the Render method of the server control, or
possible create a custom control where you specify the HTML to rendered.
David Lloyd
MCSD .NET
http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"Naveen K Kohli" <naveenkohli@.hotmail.com> wrote in message
news:#xNFQq#VFHA.1384@.TK2MSFTNGP09.phx.gbl...
I have created a user control using asp:table control. The control generates
a single column menu controls with 5 rows. each row is supposed to have a
image in link tag. The problem is that ASP.Net framework generates closing
"td" tags on new line. This causes to show extra white pixels at the bottom
of each image. This is because of a known bug in "IE" where it has issues
with closing "td" tag on new line.
Question .... is there a way to control the HTML tags generated by ASP.Net
controls so that I can get the UI the way I want it?
Thanks
Naveen K Kohli
http://www.netomatix.com