Hierarchical data
Hi
I'm a VB6 developer tasked with taking a VB6 application and turning it into
a .NET application. I'm just doing a bit of reading up at the moment...
The VB6 application does a lot of queries returning hierarchical ADO
recordsets, sometimes this goes as far as 4 chapters deep... This data is
not simply bound to a display control, but the data programmatically
iterated through and either the data manipulated or other tasks stared based
on the values found.
I'm after a quick "beginners" tutorial for handling hierarchical data and
manipulating it in a VB.NET environment. Any suggestions?
All help greatly appreciated.
Thanks
Griff Tag: Save Table in MSSQL Tag: 116471
BindingContaxt
I am trying to insert a new record into a sql table, that has a field that is
a key field. Before I can insert the record I get a message when the
statement with the '***' is executed. is there a way to code around this???
MESSAGE:
"System.Data.NoNullAllowedException: Colume 'taskid' does not allow nulls".
I know this. What I do not understand is how the 'BindingContact' really
works. Some of the code follows:
CODE:
DataRowView drvDetail;
DataView vueDetail;
public void EditDetail(CurrencyManager cm)
{
try
{
LoadData();
cbServices.DataSource = dvServices;
cbServices.DisplayMember = "service-description";
cbServices.ValueMember = "service-nbr";
drvDetail = (DataRowView) cm.Current;
vueDetail = drvDetail.DataView;
*** this.BindingContext[vueDetail].Position = cm.Position; ***
txtSON.DataBindings.Add("Text", vueDetail, "service-order-number");
txtTaskID.DataBindings.Add("Text", vueDetail, "taskid");
txtServiceDesc.DataBindings.Add("Text", vueDetail, "task-desc");
txtCompDate.DataBindings.Add("Text", vueDetail, "complete-date");
txtServiceCost.DataBindings.Add("Text", vueDetail, "task-cost");
-
Norm Bohana Tag: Save Table in MSSQL Tag: 116465
Emergency! Too Busy A Connection!
Hi.
I have a problem with an OLEDBConnection object that is supposed to serve for
a number of clients that need data from my Access(mdb) database.
These clients are placed in different threads and try to load data from this
connection. The problem is that when the connection is retrieving data for
one of them, another one may ask for data. This throws an
InvalidOperationException with the following message:
"ExecuteReader requires an open and available connection. The connection's
current state is Open, Executing."
I fully understand its meaning, but what can I do to solve this issue?
I tried a delaying loop, checking to see if the exception occurs again in
the loop,
and repeating the operation again. Although I used Application.DoEvents (you
know what that does) , but a loop takes all the CPU time available, and it
seems to me that the whole operation becomes very very slow and surprisingly,
memory consuming!
Any one got an idea?
Thank you all. Tag: Save Table in MSSQL Tag: 116464
FUNCTION as DATASET
I am trying to create a function that passes a Dataset. I know the code
works because if I cut and paste it on my file in code behind it works
fine.
The actual task is to create the Dataset from a SQLDataAdapter within a
function. Then I want to call the function to fill a dropdown list on
my .aspx page.
Here is the current code that I am using in the function. I am unaware
of what I should be using on the .aspx page.
Any and all help is appreciated.
Public Function ShowRootFolders(ByVal ClientID As String) As DataSet
Dim Connect As String
Dim CompanyDataSet As DataSet
Dim GetCompanys As SqlClient.SqlDataAdapter
Connect =
ConfigurationSettings.AppSettings("THE_Connection")
Dim Connection As New SqlClient.SqlConnection(Connect)
Connection.Open()
GetCompanys = New SqlClient.SqlDataAdapter("Select * from
rootfolders where clientID = '" + ClientID + "'", Connection)
CompanyDataSet = New DataSet
GetCompanys.Fill(CompanyDataSet, "AllTables")
DMConnection.Close()
Return ShowRootFolders Tag: Save Table in MSSQL Tag: 116460
transaction with unknown nbr of commands
Using vb.net for code behind on a asp.net application.
I need to run a number of sqlcommands, based on user input. The commands
need to run as a single transaction. The commands are all stored procedures.
How do I do this? I was thinking that I could build an array of the
sqlcommands, but I do not see how to do it. I looked at arraylist, but still
not sure.
Maybe the question could be stated as:
When I run a sqlcommand in a transaction, does the sqlcommand need to
persist, or can I just reuse it to run another stored procedure within the
same transaction? Tag: Save Table in MSSQL Tag: 116455
SQL debugging
I have setup my project for SQL debugging. I get the error message
Unable to start SQL Debug session.
Ensure SQLDBREG2.exe and Proxy/stub dllsqldbg.dll are registred on this
machine.
How do I get these registered? Tag: Save Table in MSSQL Tag: 116453
Object reference not set to an instance of an object - Exception in System.Data.OracleClient
Hello NG,
We are facing sometimes the following exception
...
Object reference not set to an instance of an object.
------------------------------ Stack Trace ------------------------------
at System.Data.OracleClient.DBObjectPool.GetObject(Object owningObject,
Boolean& isInTransaction)
at
System.Data.OracleClient.OracleConnectionPoolManager.GetPooledConnection(String
encryptedConnectionString, OracleConnectionString options, OracleConnection
owningObject, Boolean& isInTransaction)
at
System.Data.OracleClient.OracleConnection.OpenInternal(OracleConnectionString
parsedConnectionString, Object transact)
at System.Data.OracleClient.OracleConnection.Open()
at Philips.Phoenix.PhoenixAgent.StandardWebForm.Page_Load(Object sender,
EventArgs e)
...
when executing this code:
...
DbCon = New
System.Data.OracleClient.OracleConnection(ConfigurationSettings.AppSettings("OracleConnectionString"))
DbCon.Open()
...
The exception only occours sometimes, but as soon as it occours once it's
appearing more and more, with the result that the application is no longer
responding.
Is this a known issue? Are there any ideas to work arround that ?
Thanks and Regards
MBO Tag: Save Table in MSSQL Tag: 116452
What is threadsafe mean ?
Hi,
I am newbie to multithread programming.
When I read some writeup about classes, i.e. Dataset or Dataview
sometimes it said it is safe for multithreaded read operations and you must
synchronize any write operations.
What does the above statement means ?
Thank You,
mfwoo Tag: Save Table in MSSQL Tag: 116437
How to determinate the vesion of Sql2005
The user of my asp.net program use Sql2005 or Sql2005 express as database,
both are possible.
I have try both version of data base, I found:
If I use Sql2005 express, the Data Source in connection string will be
.\SQLEXPRESS, like:
Data Source=.\SQLEXPRESS;Initial Catalog=myDB;Integrated Security=True
But I use Sql2005 , the Data Source in connection string can be use
(local), like:
Data Source(local);Initial Catalog=myDB;Integrated Security=True
My questions are:
1.Is it possible use the some connection string with both version of
DataBase.
2. If question 1 is impossible, how to determinate the version of Sql2005?
I want to composite the connection string with program. Tag: Save Table in MSSQL Tag: 116429
Textbox DataBinding
I don't fully understand control binding in c# programs and wonder if
someone could clarify things for me.
I have two related tables ...
Parent: USERS (names)
Child: USER_CONTACT (telephone numbers, etc)
To the child table I've bound several textboxes as follows ...
myTextbox.DataBindings.Add("Text", ds.USERS, "USER_USERCONTACT.FIELD_NAME");
All of this works great. My problem is updating the datasource with changes
made to the textbox values. Specifically, the routines below successfully
pass updates to the datasource just once. After that, in spite of making
more edits, the routines don't pass changes back to the datasource.
Here are the main events in the code ...
BindingContext[ds.USERS, "USER_USERCONTACT.FIELD_NAME"].EndCurrentEdit();
daUSERS.Update(ds.USERS);
daUSERS.Fill(ds.USERS);
daUSERContact.Update(ds.USER_CONTACT);
daUSERContact.Fill(ds.USER_CONTACT);
Since my controls remain bound through the update and refill I assume that
maybe "EndCurrentEdit()" has ended my editing session and, for additional
editing, I need to somehow "begin edit." It's at this point that I realize
the greater problem is my not having any idea what I'm doing!
Thanks in advance for advice. Tag: Save Table in MSSQL Tag: 116428
Why can run with Users
I use VS2005 to develop Asp.net program.
If the asp.net just belong to Users group, my aps.net can't run. It's error
message is : "Login failed for user 'D610\ASPNET' (D610 is my machine name)
But if I add Administrators to Asp.net account, my asp.net program can run
well.
Why? I have found the other machines can just use asp.net with Users to run
asp.net program! Tag: Save Table in MSSQL Tag: 116427
Backup do but Restore fail
I want to backup and restore a database in asp.net.
The backup process is successful and fail when restore with message:
User does not have permission to RESTORE database 'Health'.
RESTORE DATABASE is terminating abnormally
the restore SQL is :
restore database Health from disk =
'D:\Data\ASPNET\Health8\Backup\myback.bck'
and the backup SQL is:
backup database Health to
disk='D:\Data\ASPNET\Health8\Backup\myback.bck' with init
The two state are all execute in asp.net, why the backup one can do, but the
restore on fail with no permission?
I have also test the Restore statement in Enterprise manager, it done
sucessfully. Tag: Save Table in MSSQL Tag: 116415
How to Store Multidimensional DataSet (.NET 1.1)
Hi,
I want to read a bunch of related tables into a DataSet, update some data in
some of the tables and save the changes back to the database. How can this
be done? Can someone please point me to a corresponding tutorial? I've been
searching through MSDN but couldn't find anything appropriate. When I use
the SqlDataAdapter to read more than one query, all the tables get names
different from the query source table name. How is it supposed to store it's
data back into the database then? And how can I have DataRelation objects
automatically created from my query? (E.g.: "SELECT * FROM Order; SELECT *
FROM OrderItem; SELECT * FROM Address")
Thanks for enlightening me!
Axel Dahmen Tag: Save Table in MSSQL Tag: 116413
How to select a sequence of datetime records
I have a table where the records are inserted in intervals of 500ms. I need
create a SP where the records are selected in the following basis:
1. One of the fields is a datetime type
2. An initial datetime is provided as an argument
3. I need read the first 400 records (for example) where the first record is
the one provided as argument and the subsequent records will be the initial
datetime value added in steps of 5 min.
For example:
if the provided argument is 08/20/2005 14:22, the I need to get
08/20/2005 14:27
08/20/2005 14:29
08/20/2005 14:34
and so on....
any ideas?
Thanks.
Carlos
--
Senior Developer
www.byteshift.com Tag: Save Table in MSSQL Tag: 116407
How to join two tables.
i have two tables as follows:
first table:
Id Name Age
2 ABC 21
3 XYZ 22
second table:
Id Salary Exp
2 10000 2
3 20000 5
The Id columns in both the tables being the primary keys.
and wat i want is
Id Name Age Salary Exp
2 ABC 21 10000 2
3 XYZ 22 20000 5
is this possible? I tried using dataset.Merge and binding dataset to
the datagrid to display the final table, but with no success.
any pointers to this will be greatly appreciated. Tag: Save Table in MSSQL Tag: 116405
ALTER USER in Oracle returns ORA-01036 error
Hello.
I have a VB.NET windows application using .NET Framework 1.1 and
System.Data.OracleClient.dll version 1.0.5000.0, connecting to
Oracle10g database.
I had no problem running OracleCommand.ExecuteNonQuery() passing
OracleParameters.
But now, I want to add an option to allow to change the password of
Oracle database users through my application.
I have this simple code:
Dim cmd As New OracleCommand
With cmd
.Connection = Conexion
.CommandType = CommandType.Text
.CommandText = "ALTER USER :param0 IDENTIFIED BY :param1"
.Parameters.Add(New OracleParameter("param0", User))
.Parameters.Add(New OracleParameter("param1", NewPassword))
'where User and NewPassword are string variables
End With
Conexion.Open()
cmd.ExecuteNonQuery()
But I get this error:
"ORA-01036: illegal variable name/number"
I have tried changing System.Data.OracleClient.dll to the 1.0.3300.0
version but I get the same error.
I would appreciate any help!!!
Thank you. Tag: Save Table in MSSQL Tag: 116394
fabricated dataset in VB.Net
I want to create a fabricated dataset in VB.Net.
Any help would be welcome.
TIA
Chris Tag: Save Table in MSSQL Tag: 116389
Empty SQLDataReader when using SQLCommand parameters
We are having issues getting data from our sql database using a stored proc
w/ parameters. the dr.HasRows is always false. the sp returns data with the
same parm in query analyzer. this also returns data when we use cmdtype =
text and hard code the sp in the cmdtext. it also returns data with an sp
that has no parameters. thanks in advance for you help.
Here is the code:
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Persist Security Info=False;User
ID=sa;Initial Catalog=ace;Data Source=devsql");
SqlCommand cmd = new SqlCommand("userget", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter parm =
cmd.Parameters.Add("@Username",System.Data.SqlDbType.VarChar,128,"username");
parm.Direction = System.Data.ParameterDirection.Input;
parm.Value = "[some username in the database]";
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
Console.WriteLine("Has Rows");
}
}
} Tag: Save Table in MSSQL Tag: 116388
Speed issues with ADO.Net
I've converted an old VB3 program that loops through the lines of a
text file, then uses that info to write to a database. I use mostly
OLEDB DataAdapters, DataSets, and DataTables and Rows to insert/update
the database. The problem is, this is extremely slow (with one
extremely large file, the old program completed in 9 minutes, while the
new program took 1 hour 9 minutes!). I'm considering replacing the use
of dataadapters etc. with just SQL commands using an OLEDBCommand. Is
this the best alternative to increase speed?
This is an extremely large, old program that calls different
subroutines based on the line read from the text file. Basically, in
each sub, I'm creating new DataAdapter, DataSet, and DataTable and Row
objects, and using them. Tag: Save Table in MSSQL Tag: 116380
Unchecked checkbox windows form
Hi:
I'm sure this question has been asked before but I can't find the answer.
I have a windows form with a checkbox. It's bound to a BIT field in sql
server. I let the wizard create the dataadapter and the stored procs in the
database. If the box is unchecked when I insert a new record, it leaves the
field in the database NULL which throws an error when I try to load the
record. How can I pass False or 0 to the stored proc? Is there a setting
somewhere? To tell the truth, I have a lot of checkboxes so I was hope I
could change a setting instead of hand code all the bidings for it.
I set the default value in the table to (0) but still shows NULL or grey box
in the table when my form inserts
Thanks
RK Tag: Save Table in MSSQL Tag: 116371
how do I remove extra data from serialize XML string of a DataSet
Hi All,
I want to serialize an object which contain the DataTable. As DataSet
is MarshalByRef object and is serializable. I am using it directly.
Even my data is also serialize and save it to XML file.
Now as DataSet serialize, it's creating some extra information schema
information), And i don't need that. I only want to store the data in
XML format. I don't want to store extra details like namespace etc...
As it's increase XML file size.
Inshort, I want XML string of a DdataSet excluding other data like
type, namespace etc....
One thing is clear that this DataSet is a part of my object. So I can't
use DataSet.GetXML() function.
Thanks
Rushi Tag: Save Table in MSSQL Tag: 116369
how do I remove extra data from serialize XML string of a DataSet
Hi All,
I want to serialize an object which contain the DataTable. As DataSet
is MarshalByRef object and is serializable. I am using it directly.
Even my data is also serialize and save it to XML file.
Now as DataSet serialize, it's creating some extra information schema
information), And i don't need that. I only want to store the data in
XML format. I don't want to store extra details like namespace etc...
As it's increase XML file size.
Inshort, I want XML string of a DdataSet excluding other data like
type, namespace etc....
One thing is clear that this DataSet is a part of my object. So I can't
use DataSet.GetXML() function.
Thanks
Rushi Tag: Save Table in MSSQL Tag: 116368
C#-Oracle Ref Cursor?
Hi,
I am using Oracle9i and developing a program with C#. I use ADO.net
(System.Data.OracleClient) to connect to db. I get the data by using ref
cursors. But i have a problem about maximum number of opened cursors. I
cannot close the ref opened cursor explicitly by C#. ADO.net does not close
the cursor by disposing all database objects such as
OracleCommand,Connection... So, i get an error message when i exceed the
maximum number of opened cursors. It is set to 1000. So is is it possible to
close opened ref cursors by C#.Thanks... Tag: Save Table in MSSQL Tag: 116365
Null value and storedproc parameter
I add a patrameter using the following:
MyParam.Value = IIf(MyIntData = 0, vbNull, MyIntData)
So if MyData = 0 then replace it with a null, thing is when the storeproc
executes I get a FOREIGN KEY constraint error, which suggests that a zero is
being passed and not a null (yes the column allows null values).
Am I missing something obvious ?
Thanks !
Séan Tag: Save Table in MSSQL Tag: 116364
How to know the file name of a database
I want to copy the .mdf and .ldf of a database when the database is detatch.
How can I get physical file name a database? Tag: Save Table in MSSQL Tag: 116359
How can I restore a database when the database is deleted?
I use
backup database pubs to disk='c:\pubbackup.bak'
to backup pubs database.
Then I detach pubs, and delete pubs.mdf and pubs.lof
After delete the files, I use
restore database pubs from disk='c:\pubbackup.bak'
to restore database form backup file, but it fail with message: "Can't find
pubs database"
How can I restore a database when the database is deleted? Tag: Save Table in MSSQL Tag: 116357
What happened to Eval, Execute and ExecuteGlobal
I have been trying to get find where the simple Eval function that was such a
great little function in asp has gone. There does not appear to be any
replacement. Is this possible??
I was using this in a number areas in my asp app and when I have gone to
upgrade I can't seem to find any similiar functionaility - There must be
something out there?
I noticed that datalist has an Eval - is this similiar - it appears to
evaulate things at run-time - could this be used as a replacement.
I can't believe that it is impossible - you are meant to be able to create
web controls - and if I am correct that the datalist has an eval, than it
should be possible to buid Eval functionality into any control - just can't
find anything on this one.
Any help would be great.
--
matthew Tag: Save Table in MSSQL Tag: 116355
thanks everyone
Thanks everyone who has helped me the last few weeks getting my most
complicated input screen done. Now I only have 4 or 5 more to do, but they
should not be as hard since everything I didn't know, I think I learned on
the main screen from people in here.
--
Patrick Sullivan, AA-BA, BA-IT Tag: Save Table in MSSQL Tag: 116350
Unexplained error when databinding
I am using a DataSet as the DataSource of a DataList in my code. The SQL
used to get the data from the database begins with:
SELECT
members.organization,artists.artist,artists.email,artists.website,members.email
FROM members INNER JOIN artists ON members.memberid=artists.memberid WHERE
Notice that both tables involved in the SELECT statement have a field named
email. First, I do not know how to specify which one I want in my
databinding expressions (I tried DataItem.artists.email and
DataItem.members.email, but that gave me an error too). Second, I know that
my DataSet is getting filled correctly because my first databinding
expression worked (see line 71 in the error). My error is as follows:
Server Error in '/' Application.
--------------------------------------------------------------------------------
DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with
the name email.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.HttpException: DataBinder.Eval:
'System.Data.DataRowView' does not contain a property with the name email.
Source Error:
Line 70: <ItemTemplate>
Line 71: <asp:Label id=lblOrganization1 runat="server" Width="175px"
text='<%# DataBinder.Eval(Container, "DataItem.organization")
%>'></asp:Label>
Line 72: <asp:HyperLink id="lnkPresenterEmail1" runat="server"
Width="175px" text='<%# DataBinder.Eval(Container, "DataItem.email") %>'
NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}")
%>' Target="_blank"></asp:HyperLink>
Line 73: <asp:Label id=lblArtist1 runat="server" Width="125" text='<%#
DataBinder.Eval(Container, "DataItem.artist") %>'></asp:Label>
Line 74: <asp:HyperLink id=lnkEmail1 runat="server" Width="175"
text='<%# DataBinder.Eval(Container, "DataItem.email") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}") %>'
Target="_blank"></asp:HyperLink>
Source File: D:\Clients\12654\papresenters.org\papresenters.org\search.aspx
Line: 72
Stack Trace:
[HttpException (0x80004005): DataBinder.Eval: 'System.Data.DataRowView' does
not contain a property with the name email.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName) +146
System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts)
+71
System.Web.UI.DataBinder.Eval(Object container, String expression) +82
ASP.search_aspx.__DataBind__control34(Object sender, EventArgs e) in
D:\Clients\12654\papresenters.org\papresenters.org\search.aspx:72
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataList.CreateItem(Int32 itemIndex,
ListItemType itemType, Boolean dataBind, Object dataItem) +127
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean
useDataSource) +683
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +23
PAPresenters.search.btnSearch_Click(Object sender, EventArgs e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300
Can anyone help me with this? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/ Tag: Save Table in MSSQL Tag: 116347
Help - sever control state not being saved
When I set my ASP.NET project IIS directory security with:
Anonymous Access checked and a valid domain account is supplied; and
Integrated Security is unchecked - none of the state changes in my server
side user controls hold?
Also any Response.Redirect statements fail.
Any thoughts from the peanut gallery would be great.
Thanks. Tag: Save Table in MSSQL Tag: 116345
System.Web.ProcessModelInfo.GetHistory(10)
This "System.Web.ProcessModelInfo.GetHistory(10)" will return a history
about recent worker processes. The types of information it will return are
Process ID, Start Time, Peak Memory Used (in KB) and Shutdown Reason. Is
there a way to get this history from a Remote Server? Tag: Save Table in MSSQL Tag: 116340
Are DataViews thread safe?
I know DataSets are threadsafe, but what about DataViews from the DefaultView
accessor? Here's the situation: ASP.NET application; DataSets in the Cache;
Each session gets a DataView from each DataSet via DefaultView, applies a
filter to that DataView, and displays the result to the user. From what I
understand, if two threads grab the same DefaultView from the same DataSet,
and each applies a filter to it, the data displayed to both users will be the
same (it will be what is allowed by the last filter applied). Is this true?
Right now, when I grab the DefaultView, I Copy() the DataTable before. The
DataTables might contain a million or so entries, so this could bog stuff
down in the extreme case... Tag: Save Table in MSSQL Tag: 116339
Concurrency Issues Autonumbers
Hey Folkes:
I a general question regarding autonumbering. I see a lot of posts with
people having trouble with inserting records with autonumber fileds. I see
people suggesting Scope_Identity() and @@IDENTITY and ways to prevent each
other from stomping all over each others parent ID.
I was woundering, why not immediately do an da.update(DS) after an insert
just to get parent and foriegn keys in? Then begin editing the record.
Then noone else can get that ID while your filing in all the fields. You've
already inserted the record. At this point, your only edit an existing
record. Unless there is something I'm missing, you shouldn't even have to
Ds.Clear() and da.fill(DS) if your using @@IDENTITY because the DA now has
the actual parent ID upon update.
I know it's an extra round trip to the data source but is it realy that
costly on the network? Especialy if your using SP's.
Is there something I'm missing or is @@IDENTITY the answer to my question?
Also, I have a question. I've been cheating a bit. I've been using
txtChildMyID.Text = txtParentMyID.Text to populate text fields bound to the
foriegn key fields to insert the correct ID number in the child table. So
far it's been working in a 5 user environment.
My sqlDA's and DS's and storedProc's were generated using the wizards. I
can't figure out how to get the ParentID from the storedproc to pass it to
the param for the child's. I tried SET @MyIdent = @IDENTITY or SET @MyIdent
= Scope_Identity() but my app just throws an error. System Error with no
other description.
TIA Bob Tag: Save Table in MSSQL Tag: 116334
Changing a field in the SQLDataAdapter to allow null values.
Hi everyone,
I am trying to set some fields in a table to a null value on purpose. I'm
using the ADO SqlCommand class and setting Parameters for the fields that I
want to be null.
cmd.Parameters("Field1").value = DBNull.Value
This seems to be working fine. The output fields show as <null> in my table.
Now my problem... The fields that I am setting to null, were originally set
in the SQL Server Table as not allowing nulls. In addition, I have an
SQLDataAdapter that was created before I made this change (to allow nulls in
the field). My App now crashes when it attempts to Fill the SQLDataAdapter,
giving the error
""An unhandled exception of type 'System.Data.ConstraintException' occurred
in system.data.dll
Additional information: Failed to enable constraints. One or more rows
contain values violating non-null, unique, or foreign-key constraints."
The SQLDataAdapter obviously doesn't like my new <null> value field. So how
do I fix this? I don't see any properties that relate to constraints
associated with the DataAdapter.
I'd just bite the bullet and re-create the SQLDataAdapter(s), but it's used
in several DataSets (and related to other tables) and I'd prefer not to have
to re-do all that.
Any suggestions? Is this error coming from the DataAdapter or from the
DataSet?
BBM Tag: Save Table in MSSQL Tag: 116331
How2 Flush to Disk DataSet.WriteXML(FileName,XMLWriteMode.WriteSch
VB.Net 2003
Windows Form Application.
A user session consists of long transactions (15- 30 minutes) where data is
stored locally in memory and then submitted to the server at the end of the
transaction for permanent storage. The problem is that if something goes
wrong with the client machine or application the memory data is lost. The
data is stored locally in a dataset. Our solution is to frequently do a
DataSet.WriteXML(FileName,XMLWriteMode.WriteSchema). This works very well in
all situations except one so far. (If the applications crashes, the XML file
is available on the local disk and we have routines to recover it and pick up
where the user left off. (That's what we want). If the computer crashes,
again, the XML file is there. But if the application and/or machine locks up
(or appears to lock up) and the user performs an End Task on our application
from the task manager, the XML file is not written. Note: To test, I can see
the FileName.xml file exists after the first execution of writexml but the
size is 0 bytes (Per Windows Explorer). It stays 0 bytes no mattter how large
in memory it becomes. (Alt Tab to toggle between the app and Explorer -with
refresh always shows 0 bytes). Even though Explorer says 0 bytes, if I then
pull the plug on the PC, the XML file is actually saved to the local disk.
But if I CTL+AlT-Del and say end task from the task manager, the XML file is
Not saved to disk. (That confuses me). But in any event, I assume that if I
could flush the streamwriter(?)/XMLTextWrite after each WriteXML the problem
would be solved. Unfortunately, I can't figure out how to do so. I have tried
to DIM as seprate XMLWriter but when I write to the same writer multiple
times I then can't read it for recovery purposes becuase it appends the
entire dataset each time instead of just the new data since the last write.
I would greatly appreciate any help you can offer. I am not locked in to the
XML soultion, it just works well considering the clients don't have an
alternate database they can use and the current code is simplistic and runs
relatively fast.
Thank you
--
Jim Tag: Save Table in MSSQL Tag: 116329
executenonquery question
I have read that executenonquery() does not return any data, yet I see code
like below often enough. What's the deal? TIA
intRowsAffected = cmSQL.ExecuteNonQuery(blahblah)
If intRowsAffected <> 1 Then
MsgBox("Update Failed.", MsgBoxStyle.Critical, "Update")
End If
--
Patrick Sullivan, AA-BA, BA-IT Tag: Save Table in MSSQL Tag: 116327
Extra data comes at time of serialize DataSet
Hi All,
I want to serialize an object which contain the DataTable. As DataSet
is MarshalByRef object and is serializable. I am using it directly.
Even my data is also serialize and save it to XML file.
Now as DataSet serialize, it's creating some extra information (schema
information), And i don't need that. I only want to store the data in
XML format. I don't want to store extra details like namespace etc...
As it's increase XML file size.
One thing is clear that this DataSet is a part of my object. So I can't
use DataSet.GetXML() function.
////My XML file
<dataSet>
<xs:schema id="MarkupData" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="MarkupData" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="MarkupWrapper">
<xs:complexType>
<xs:sequence>
<xs:element name="index" msdata:AutoIncrement="true"
type="xs:int" minOccurs="0" />
<xs:element name="key" msdata:Prefix="k" type="xs:string"
minOccurs="0" />
<xs:element name="eleID" msdata:Prefix="eid" type="xs:int"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Element">
<xs:complexType>
<xs:sequence>
<xs:element name="index" msdata:AutoIncrement="true"
type="xs:int" minOccurs="0" />
<xs:element name="name" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<MarkupData>
<MarkupWrapper diffgr:id="MarkupWrapper1" msdata:rowOrder="0"
diffgr:hasChanges="inserted">
<index>0</index>
<key>IMS1</key>
<eleID>1</eleID>
</MarkupWrapper>
<MarkupWrapper diffgr:id="MarkupWrapper2" msdata:rowOrder="1"
diffgr:hasChanges="inserted">
<index>1</index>
<key>IMS1</key>
<eleID>2</eleID>
</MarkupWrapper>
<Element diffgr:id="Element1" msdata:rowOrder="0"
diffgr:hasChanges="inserted">
<index>0</index>
<name>food</name>
</Element>
<Element diffgr:id="Element2" msdata:rowOrder="1"
diffgr:hasChanges="inserted">
<index>1</index>
<name>misc</name>
</Element>
<Element diffgr:id="Element3" msdata:rowOrder="2"
diffgr:hasChanges="inserted">
<index>2</index>
<name>comp</name>
</Element>
</MarkupData>
</diffgr:diffgram>
</dataSet>
///
Thanks & Regards,
Rushi Tag: Save Table in MSSQL Tag: 116322
Display editable one-to-one data from n tables in one DataGrid...
I'm surprised nobody else seems to have had this problem. I'm developing
against a system in which stored procedures cannot be used and existing
tables must be extended with one-to-one "extension" tables.
Is it possible to bind a single DataGrid to two one-to-one related
DataTables in such a way that all columns are editable and DataAdapters can
be used to easily update the two tables afterwards? I can't use expression
columns, because they're not editable.
Do I have to go to the trouble of copying the data from the two tables into
one common table and bind to that? That would be pretty messy, especially
when it comes time to take the changes back to the original data tables for
updating the database.
I guess what I really need is for the "child" of the two tables (could be
either table as they are related by their primary keys) to have proxy
columns from the parent.
Any advice on best practices welcomed.
Nathan Tag: Save Table in MSSQL Tag: 116314
"Procedure expects parameter" when calling SqlDataAdapter.Update()
Hi,
I have a SqlDataAdapter for which I have made the UpdateCommand manually.
Both the Select and Update commands are custom stored procedures in SQL
Server 2000. The Select part works fine; I can populate a dataset and modify
it without problems. However, when I want to save the modifications in the
database, and call myDataAdapter.Update(myDataSet), I get the following
exception:
Procedure 'MyUpdateProcedure' expects parameter '@Id', which was not
supplied.
MyUpdateProcedure actually takes several parameteres, of which the @Id
parameter is the first. All parameters have corresponding columns in one of
the DataTables (in myDataSet). All parameters (including @Id) are
represented in the UpdateCommand.Parameters collection, and everything looks
correct in the SqlDataAdapter.TableMappings collection (the correct table
name is specified, and all parameters points to the corresponding dataset
column). What else do I have to do?
I'm so frustrated that I've actually considered looping through the modified
rows and updating the database manually - something I of course want to
avoid...
Any help is greatly appreciated!
Regards,
Nils Magnus Englund Tag: Save Table in MSSQL Tag: 116313
Problem with executing a DTS from a remote machine
Hi all,
We've created a VB.NET application which runs a couple of DTS packages on a
SQL Server in a specific order using ADO.NET. When we runs this application
on the same machine that SQL Server resides on it works fine. However when
we run the application on another machine in the domain the first package is
started but it doesn't finish.
This package is a straightforward one: truncate a table, copy records
(approx. 10.000.000) from one database table into the table which has just
been truncated and finally create a couple of indexes. This step takes about
30 min. to complete. When we run it from a remote machine we can see that
the table has been truncated however there are no records copied into it.
When we look in the Proces Info in SQL Server the proces which is running
the package has a status of: wait and as command: NETWORKIO. The wait time
increases gradually.
Does anybody know what the problem could be?
TIA,
Friso Wiskerke Tag: Save Table in MSSQL Tag: 116311
"Timeout expired" for simple query
Hi,
I've made a HttpModule which deals with user authentication. On the first
request in a users session, it fetches data from a SQL Server using the
following code:
using (SqlConnection connection = new
SqlConnection(ConfigurationSettings.AppSettings["Database.Connection"]))
{
connection.Open();
SqlCommand sqlCommand = new SqlCommand("GetAdvisorEnterpriseLogin",
connection);
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.Parameters.Add("@InputUsername",
HttpContext.Current.User.Identity.Name);
SqlDataReader reader = sqlCommand.ExecuteReader();
reader.Read();
username = (string) reader["Username"];
password = (string) reader["Password"];
reader.Close();
}
The "GetAdvisorEnterpriseLogin" procedure is a really simple one, and hardly
takes 0.1 second to run.
However, the first 1-3 times I access the page after a recompile (and once
in a while otherwise), I get the following exception:
Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding. Description: An unhandled
exception occurred during the execution of the current web request. Please
review the stack trace for more information about the error and where it
originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Timeout expired. The
timeout period elapsed prior to completion of the operation or the server is
not responding.
I also get the exception after not using the system for a while, but I
haven't experienced when the system is "in use", i.e. when the previous
request was no more than a couple of minutes ago.
Does anyone know what could cause this error, and how I can prevent it from
happening?
Regards,
Nils Magnus Englund Tag: Save Table in MSSQL Tag: 116308
error -532459699
Hi,
In my client-server application (BD ms-access2002), I have the folowing
error when I update the DB (dataadapter.update(dataset,"tblname"))
{System.InvalidOperationException}
code:-532459699
hresult: -2146233079
message: "" (no message)
This code was working for many months.. I don't know what happened!!!!!!
Any help please.. Tag: Save Table in MSSQL Tag: 116307
TSQL update parameters problem?
I have been having problems updating rows with my VB 2003. New rows save
fine. Updates have consistently given me system.data errors no matter
whether I use stored procs or TSQL.
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred
in system.data.dll --- Additional information: System error.
This is what SQL Server Profiler logs from my data adapter when I try to
send an update:
UPDATE Applications SET AppCompany = 87, appPosition = 65, appMethod = 5,
appDate = 7/20/2005 5:55:00 PM , appNotes = 'test on 8/6/2005' WHERE appID =
106
Query analyzer says this when I check the syntax:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '5'.
What is wrong? Does the date field need to be in quotes? TIA
--
Patrick Sullivan, AA-BA, BA-IT Tag: Save Table in MSSQL Tag: 116304
SQL Server 2005/ ADO.NET 2.0 Begin Transaction Issue
I have an application that was originally built in VS 2003 and successfully
running against SQL Server 2000 and SQL Server 2005 (June CTP). Recently, we
migrated to VS 2005 Beta 2 and are running on SQL Server 2005 (June CTP)
exclusively. Since the migration, we have some situations where we receive
the following exception when attempting to begin a SQLTransaction:
Exception Type: System.Data.SqlClient.SqlException
Number: 3988
Message: New transaction is not allowed because there are other threads
running in the session
Stack Trace:
StackTrace Information
*********************************************
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj)
at
System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[]
buffer, TransactionManagerRequestType request, String transactionName,
TransactionManagerIsolationLevel isoLevel, Int32 timeout,
SqlInternalTransaction transaction, TdsParserStateObject stateObj)
at
System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest
transactionRequest, String transactionName, IsolationLevel iso,
SqlInternalTransaction internalTransaction)
at
System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest
transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction
internalTransaction)
at
System.Data.SqlClient.SqlInternalConnection.BeginSqlTransaction(IsolationLevel iso, String transactionName)
at System.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel
iso, String transactionName)
at System.Data.SqlClient.SqlConnection.BeginTransaction()
I haven't been able to find any information about this error and I was
wondering if anyone had ideas about the cause of the exception and why it is
an issue with VS 2005 Beta 2 but not in VS 2003.
Regards,
Robert Kihm Tag: Save Table in MSSQL Tag: 116294
ADO and Unify Dataserver
Hello Everyone,
Any of you have tried to connect a asp.net app with this database? because
im searching on the internet and nothing related appears, this database its
only accessible by odbc and Im getting issues with the execution of store
procedures with odbccommand object, any ideas, url's suggestions (database
changing is not the possible solution!!)
Thanks in advance
KMILO Tag: Save Table in MSSQL Tag: 116293
String.Length
Hi. I've got a vb.net/asp.net application that passes strings back a
forth between a c++ COM object. We use simple tagging to designate
what's what, and it's worked pretty well until now. We had some data
that wasn't parsing right because it also contained tags that conflicted
with the tags designating the data.
To get around this the programmer of the COM object (not me) decided we
could put string lengths in the tags, so if an element was called x, I'd
send <x L=3>123</x> with the L= indicating the length of the string. So
I wrote a tagging function to take care of this that uses the
String.Length property to calculate the length of the string. So I send
the following string, and he can't parse it out:
<body L=579>Dear MATT B---
Thanks for purchasing Print@Home tickets!
Included in this this email is a link to your ticket(s) from sale id
**SUB(wwsale_id).
To retrieve your tickets, please click (or copy/paste into your browser)
the link below:
<http://localhost/webwaresales1/GetTix.aspx?req=kXU%2bANUsFnl4YlNHjua5lA%3d%3d>
You will need Adobe Acrobat Reader (available free from
http://www.adobe.com)
to view or print your items.
You will need to bring your printed tickets with you to the resort.
Thanks again and we look forward to seeing you soon!
S---------, Inc.</body>
The other guy said he calculates a length of 551 but if I use
String.Length I get 579. Incidentally, if I paste the string into
TextPad and look at the document properties, it says 551 characters and
a file size of 579, which is what I got for String.Length.
So can anyone explain where the difference (28) comes from? It's not the
number of lines (15) and I don't see any other special characters
besides line endings.
Thanks!
Matt Tag: Save Table in MSSQL Tag: 116291
dataview row question
How do I assign row to the dataview filter?
Dim conn As New SqlConnection(ConnectionString)
Dim dtAdapter As New SqlDataAdapter("SELECT * FROM myTable", conn)
Dim myData As New DataSet
conn.Open()
dtAdapter.Fill(myData)
conn.Close()
Dim dv As DataView
dv = myData.Tables(0).DefaultView
dv.RowFilter = ("rowID = " + record.ToString) ' record is an int32, already
set
Dim row As DataRowView
row. ??
row.Item("Company") = txtCompany.text
row.Item("Address1") = txtAddr1.text
--
Patrick Sullivan, AA-BA, BA-IT Tag: Save Table in MSSQL Tag: 116285
Hello Group,
In my application I create new DataTable (name : myTable). How save this
table on sql server as myTable.