SqlExpress & C# problem in an ASP.NET web site
I'm trying to create a SqlServer express database file on the fly in a web
application..
(mhh.... maybe I should try to get something running in a desktop
application first?)
Anyway I want to connect to a database file and, if it doesn't exist, create
the DB on the fly.
Actuall I'm trying to create the connection like that:
I'm trying to create a connection like that:
===
public static SqlConnection GetConnection(string filename)
{
string connString = @"Data
Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|{0}.mdf;Integrated
Security=True;User Instance=True";
connString = string.Format(connString, filename);
SqlConnection sqlc = new SqlConnection(filename); // <= exception here
return sqlc;
}
===
It fails with "Format of the initialization string does not conform to
specification starting at index 0."
mmh..
is it because the file doesn't exists?
How am I to connect to SqlServer to run the SqlSever creation script if my
file doesn't exist?
Should I embed an empty database as a resource in my control library if I
want to automatically create the database?
Or is there an other way? (I have the creation Sql script ready, I just
wonder how to run it).... Tag: How to use backgroupworker to load dataset? Tag: 122741
Conectar BD
Hola a todos y Feliz año 2006:
Tengo que crear una aplicación que accede a una Base de datos, y los datos
cambian constantemente en las tablas de la Base de datos, esos cambio son
nuevos registros.
Hasta el dia de hoy estado utilizando el componente DOA para Oracle, y estoy
permanentemente conectado a Oracle y cada vez que hay un nuevo registro
automaticamente se actualizan todas las pantallas de los clientes.
Cada cliente que utiliza la aplicación abre una conexión a Oracle y ésta es
permanente, se cierra solo cuando sale de la aplicación.
Ahora bien, en VS2005 como puedo hacer esto?? ya que aqui tengo en tendido
que se trabaja en MODO DESCONECTADO.
Ustedes, que me recomendarían?? como debo implementarlo con VS2005??
Agradecería mucho su valiosa ayuda.
Un saludo a todos y que este 2006 sea de mucha alegria., amor pa todos.
EWAT Tag: How to use backgroupworker to load dataset? Tag: 122739
About datatables
Hi
How to pass the content of one data table to another data table.I simply
tried using assignment operator...Example: datatable1=datatable2...But,its
not working..
ravindra Tag: How to use backgroupworker to load dataset? Tag: 122730
TableAdapter Performance
Hi,
Have anyone ever benchmark the TableAdapter performance compared to
DataTable's Load method? I found out that the DataTable's Load method is
about 10x faster than TableAdapter's Fill method.
I used the same SELECT query and DataSet (predefined), for both test.
For the DataTable's Load method, we first need to create a DataReader.
Anyone know why? Or is there any other configuration needed to make
TableAdapter faster?
Thanks for reading. Tag: How to use backgroupworker to load dataset? Tag: 122728
How to bind an object to a table
Hi,
I am new to .net. I think .NET provides what I need, but I don't
know how to implement it.
What I need is simply associating an object with a database
table. I would like to load "objects" from table, and I would like to
modify or delete objects, without dealing with database in anywhere. In
other words; I do not want to write SQL query for any of those
operations. Let me give you an example (in C++/CLI):
ref class MessageBase abstract
{
String^ m_strFrom;
String^ m_strBody;
String^ m_strSubject;
DateTime m_dtRecSent;
DateTime m_dtReplied;
DateTime m_dtForwarded;
MessageTypes m_mtType;
public:
property String^ From { String^ get(); void set(String^); }
property String^ Body { String^ get(); void set(String^); }
property String^ Subject { String^ get(); void set(String^); }
property DateTime ReceivedDate { DateTime get(); void
set(DateTime); }
property DateTime RepliedDate { DateTime get(); void
set(DateTime); }
property DateTime Forwarded { DateTime get(); void set(DateTime);
}
property DateTime SentDate { DateTime get(); void set(DateTime); }
property MessageTypes MessageType { MessageType get(); void
set(MessageTypes); }
};
I have got a table to store this information. I would like to
load "messages" from table at startup, through a factory (another
recommendation?). I have prepared a typed dataset, too, but I couldn't
associate it with this class. What I have done previously in C++ was a
simple adapter. Adapter was acting like a "message object" to the
application itself, any changes in the object automatically goes
database, too. As far as I have heard, after associating this class
with a table, I will not write any SQL statement.
I would be very happy, if you could enlighten me about this type
of association. I am using .NET Framework 2.0 (of course, since I am
using C++/CLI) and I do not have a performance concern with this
operation (I have heard that this type of association of an object with
a dataset is far slower than SqlDataReader way). Database is SQLite, I
am using ADO.NET class library to access database from .NET (I have
native library as well).
Thanks!
Jason Tag: How to use backgroupworker to load dataset? Tag: 122721
How to connect a DataView to an access database?
Im trying to understand DataView, to make a couple of lists of sorted data.
The 3 textbooks I have on .net dont have dataview in the index even.
Ive started by doing a database wizard. it finds the .mdb file and formats
the schema and genetated a program, I put a simple grid view in the form1
and pointed its source at the dataset.
But now I have to use DataView. Ive tried making a DataTable, and assigning
it to the dataset which only has the one table. I hook the dataview to a
second gridView. It doesnt complain, runs fine, but there is no data in the
gridView. I wired the gridView to the DataTable? still no data there.
Im searching the docs on how to use the DataView, have an example, but the
example builds up the table from scratch; I want to fill it with 2 specific
columns from the one table in the .mdb database.
Nothing Ive done gets the data into the 2nd gridView. I can manually add
columns to it, but I want the data from 2 specific columns. Seems easy.
Any suggestions appreciated. Tag: How to use backgroupworker to load dataset? Tag: 122720
newbie in search of ADO.NET code samples
Can anyone point me to step by step walk-throughs of ADO.NET code - I'd
like to get to the point of being able to programmatically work with
assigning field data to text boxes and then write back changes to the
tables.
As an aside; I started playing with Visual Studio 2003, and now VB 2005
Express. I come out of Dbase/Clipper/Foxpro/Delphi/MSAccess/ PHP-MYSQL- and
I must admit
to being driven out of my mind with datasets and dataadaptors and
datareaders - My eyes water -I just want the *data* - the levels of
abstraction from the data itself have been driving me from the .net
environment- and I'm sure I'm missing out on some good stuff - so far VB'05
has been no different in this way from VS '03 ; I need some
simple -step -by -step working code to build on - the MS Books so far have
lacked this, and the free training videos from MS only take me through a GUI
approach , whereas I want *CODE* - any pointers to this greatly
appreciated.
(While I'm at this - I appreciate the cleverness in MS's disconnected
approach to data - I do wonder however why a connected model (and thus a
simpler one) could not have been offered as well - at least in the more
amateur oriented (if I understand this correctly) VB 2005 Express ) Tag: How to use backgroupworker to load dataset? Tag: 122719
.NET 1.1 "System.Data.VersionNotFoundException" - I need a workaro
I have three related tables, and I am getting an exception when :
****************
Dim dataRows As DataRow() = ds.Tables(MappingName).Select_("",
"",DataViewRowState.Added)
dataAdapter.Update(dataRows)
******************
The exception is:
{System.Data.VersionNotFoundException}
[System.Data.VersionNotFoundException]:
{System.Data.VersionNotFoundException}
HelpLink: Nothing
InnerException: Nothing
Message: "There is no Original data to access."
Source: "System.Data"
StackTrace: " at System.Data.Common.DbDataAdapter.Update(DataRow[]
dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows)
at QuiltTrackDB.BaseSql.PersistChanges(DataSet ds, DataRowState rowState,
SqlConnection conn, SqlTransaction tran) in
C:\Projects\QuiltTrack\QuiltTrackDB\BaseSql.vb:line 594
at QuiltTrackDB.BaseSql.PersistAllChanges(DataSet ds) in
C:\Projects\QuiltTrack\QuiltTrackDB\BaseSql.vb:line 186"
TargetSite: {System.Reflection.RuntimeMethodInfo}
I think the problem might be that the table that I am trying to insert a
record into is the subject of a relational expression column for another
table that I am also inserting to in the same transaction, so removing the
expressions before persisting is my next attempt at a workaround. but any
advice would be appreciated. (This bug was found in 1.1, but it is still
there in 2.0)
I have to say I am sorely disappointed in MS and what they have NOT managed
to do over 5 or so years of ADO.NET - which is, to get the features they have
long documented - expressions and filters, working correctly.
David Rogers
Fred Hutchinson Cancer Research Center Tag: How to use backgroupworker to load dataset? Tag: 122716
OracleClient in VS2005 ???
Hi,
I am using VisualStudio 2005 (C#) and have to write a code to access
Oracle Database. I know that in .NET Framework 1.1, I could download
OracleClient namespace (System.Data.OracleClient.dll) and add
referenct to it in my project.
Can I do the same in VisualStudio 2005? When I look for OracleClient
in msdn, it says it is only for .NET Framework 1.1.
What can I use in .NET Framework 2.0?
Any help will be appreciated,
_dino_ Tag: How to use backgroupworker to load dataset? Tag: 122714
SQL Querry
Hello,
I trying to produce a querry that will accomplish the following and am not
sure how to write the statement.
I am currently using Jet 4.0 but will be using SQL Server soon.
Example Records
ID CustID Data Date Balance
1 1234 bla8 092705 42.00
2 2341 bla7 091405 14.00
3 3412 bla6 090205 32.00
4 4123 bla5 081805 65.00
5 3412 bla4 093005 34.00
6 2341 bla3 082705 19.00
What I want to accomplish is:
Return Data, Date and Balance Where Max(ID) For CustID 3412
SELECT Data, Date, Balance Where Max(ID) AND CustID = '3412'
The Querry should Return
bla4, 093005, 34.00
Any Assistance is greatly appreciated.
Chuck Tag: How to use backgroupworker to load dataset? Tag: 122700
Unexpected Timeout
I have an application that connects to sql server. Two installs of the
application are frequently experiencing the following error:
"System.InvalidOperationException: Timeout expired." We've checked and
confirmed that all connections are closed and disposed. The two sites that
are having problems with it also receive a lower than average amount of
traffic. I've had them check for deadlocked transactions and the maximum
number of concurrent connections. If anyone has any other ideas on what else
to check it would be appreciated. Thanks, Scott Tag: How to use backgroupworker to load dataset? Tag: 122699
Oracle Ref Cursor Issue in ADO.NET
Hello,
I ran into a performance issue with Oracle Ref Cursor in ADO.NET (with
VS 2003). The SQL itself runs in less than 5 seconds in SQL*Plus.
(Oracle 9i). When the same is called from ADO.NET using the microsoft
provider for oracle (system.data.oracleclient.dll version
1.1.4322.2032), the fill method takes upto 5 minutes to fill the
dataset. The result set returned is less than 100 rows and the row size
is less than 200 characters. Any ideas why this might be happening. Tag: How to use backgroupworker to load dataset? Tag: 122697
Whatever happened to ...
I seem to recall, back in the early promise days of Whidbey, that there was
talk (and even an early version) of a set of classes for mapping data
between objects and a database being a part of the release; alas I cannot
remember its name.
I know there are various ORM tools out there, and I may even look into some
of them but can anybody tell me
(a) what the Microsoft version was called when they were hyping it, and
(b) what happened to it.
Thanks. Tag: How to use backgroupworker to load dataset? Tag: 122691
Quirky response to Update command using datagrid
Using VS2003 and SQL2k.
I've noticed that if I have an expression column (or relation column) added
to the main table, I cannot do an Update without setting the
UpdatedRowSource to either OutputParameters or None. This works fine ... so
long as we do not execute two Updates in the same row, one after the other.
This causes a concurrency error.
I understand the general idea behind concurrency and the raft of issues that
can cause a "concurrency error" (did I mention that ADO.Net is SUPERB at
spitting out "concurrency errors" if you even look at the IDE wrong, but I
digress). In any event, my stored procedure doing the update returns a fresh
set of data after said update.
Okay, playing around with this a bit, I find that using the UpdatedRowSource
set to FirstReturnedRecord prevents concurrency errors when editing twice in
the same row, but of course, we would now have a concurrency error with the
expression column. So what gives? Is there a reasonable solution? Tag: How to use backgroupworker to load dataset? Tag: 122689
ado.net deleting record sql server
hello all,
Created procedure in sqlserver accepting id as parameter to delet
record.
initialized statements
Dim DeleteCommand As New SqlCommand("DeleteProc", conn)
DeleteCommand.CommandType = CommandType.StoredProcedure
dataAdapter.DeleteCommand = DeleteCommand
AddParams(dataAdapter.DeleteCommand, "testId")
At this following line i receive error
dataadapter.update(ds,"testmaster")
System.invalidoperationException
update requires a valid DeleteCommand when passed Datarow collectio
with deleted rows.
How to get along with this problem
Thanks in advance
karun
--
karuna
-----------------------------------------------------------------------
karunam's Profile: http://www.hightechtalks.com/m61
View this thread: http://www.hightechtalks.com/t231844 Tag: How to use backgroupworker to load dataset? Tag: 122677
Problem with adding new rows to dataset
Hi
I am busy with a C# Windows application. I load data from a MS Access
database into a DataSet. In my database the primary key is an AutoNumber
field.
When I load the data into the Dataset I add the following event handler to
the my OleDBDataAdapter:
[code]
adapter_MSAccess.RowUpdated += new
OleDbRowUpdatedEventHandler(DataAdapter_MSAccess_OnRowUpdate);
[/code]
The event handler code is as follows:
[code]
private static void DataAdapter_MSAccess_OnRowUpdate(object sender,
OleDbRowUpdatedEventArgs e)
{
if (e.StatementType == StatementType.Insert)
{
OleDbCommand oCmd = new OleDbCommand("SELECT @@IDENTITY FROM Absentees",
e.Command.Connection);
e.Row["AbsIndex"] = oCmd.ExecuteScalar();
e.Row.AcceptChanges();
}
}
[/code]
When I add a new rows to the datatable in the dataset for the first time
the primary key value in the new rows start at zero (0) regardless of whether
there are existing rows or not. After I update the database using
[code]
adapter_MSAccess.Update(ds, tableName_MSAccess);
[/code]
and I add further new rows, the primary key values in these new rows now are
correct according to the last primary key value in the database.
Is there a way to avoid the starting at zero of the initial primary key
values of new rows? The problem comes in when many new rows are added
initially because an error message comes up that says something like:
Column â??AbsIndexâ?? is constrained to be unique. Value â??3â?? is already present.
Any help will be appreciated. If there is a better way of going about it I
would be glad to learn about it. Tag: How to use backgroupworker to load dataset? Tag: 122676
TableAdapter Fill Code
Hello, I just purchased Visual Studios 2005. I noticed that when I drag a
control from the DataSources toolbar, or set the datasource property of a
datagridview, that code is automatically generated in the forms load event to
fill the dataset. How can I disable this feature? I normally fill my
datasets with buttons after a user enters search parameters, this feature has
become an anoyance. Can I maybe create a macro to turn erase the code?
Thanks in advance for all of your help.
--
Aaron Moore Tag: How to use backgroupworker to load dataset? Tag: 122672
dataset.merge not working correctly
Hi,
I am trying to merge two datasets into one, each dataset has one table when
I merge the two datasets I get a dataset with two tables? I need the merged
dataset to only contain one table with the merged data. Does anyone know how
to avoid this? Tag: How to use backgroupworker to load dataset? Tag: 122670
Combining fields from different tables into 1 dataset
So far the dataset just shows
Type, Benefit, Change
I want it to show
Type, Benefit, Change, Description
This should be a pretty elementary question - and I've spent 2 days on it
already.
I just want to add one field from another table into my dataset, should be
easy, but maybe it's the way it is related that is making it so difficult
(there are no totally unique fields in either table, so it needs a multi-join)
I have 2 tables in the dataset already:
Membership
BENFT
To get the Desc Field from the BENFT table, I need to relate 2 fields to
Membership
Membership.Benefit = BENFT.BNFT
Membership.Change = BENFT.BCHG
'This is what I tried so far, but it's not working
daBenefits.Fill(DsBenefits1, "Membership")
Dim relBenefit As New DataRelation("relBen",
DsBenefits1.Tables(0).Columns("Benefit"),
DsBenefits1.Tables(1).Columns("BNFT"))
Dim relBenChg As New DataRelation("relChg",
DsBenefits1.Tables(0).Columns("Change"),
DsBenefits1.Tables(1).Columns("BCHG"))
DsBenefits1.Relations.Add(relBenefit)
DsBenefits1.Relations.Add(relBenChg)
daBenefitDesc.Fill(DsBenefits1, "BENFT")
'DGMembers is the DataGrid
DGBenefits.DataSource =
DsBenefits1.Tables("Membership").DefaultView
DGBenefits.DataBind()
Thank you
Note: Membership is actually a union that I have filled for each piece into
the dsBenefits1 Tag: How to use backgroupworker to load dataset? Tag: 122662
.Net 2.0 DataTable have a lot of lacks?
it seem that data table and Expression field have a lot of Laks, it is
true?
the DataTable is powerfull of Memory relation data that bind to
controls.
so i can load data from remote service and manipulate it and after i
send update to remote service.
But, when i need to make standart operation that with SQL system is
simple,
with Datatable it's impossible.
for example think about Accounting records. i load record from remote.
and thaen
user chnge Movement and add some. now (before we update the remote
server),
how i can put on the screen balance? by loop over all rows and grouping
it manually!!
instead write Group by!!??
[in vb6 i remember the Data Environment that allow grouping!!]
have some Project that extend DataTable abilities?
also with DataColumn.Expression have a Lacke of many simple function.
like Round, have a way to extend it? Tag: How to use backgroupworker to load dataset? Tag: 122661
datarow duplication and unique key conflicts
Hi all,
I need a quick way to create a new datarow based on an existing one
change a few values and update them to the database (the duplication
should be made in the same db table).
I've seen previous posts suggesting to use the ImportRow method for the
datatable...
i've tried it..
i see rows growing in the "in-memory" datatable... but updating to
database won't work...
any suggestion?
the code i'm using is:
Dim sql As String
sql = "select * from mytable"
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
Dim cm As New OleDbCommand(sql, Conn)
da.SelectCommand = cm
Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(da)
da.Fill(dt)
dt.ImportRow(dt.Rows(0))
dt.Rows(3)("myid") = 12
da.Update(dt)
"myid" is a numeric primary key Tag: How to use backgroupworker to load dataset? Tag: 122656
Dataset to table
Hi
I have a sub method that has been passed a dataset as parameter. I need to
insert this dataset into a table. What is the code that I need to do this?
The dataset does not have any conflicting keys so it is a very easy scenario
from conflict resolution point of view.
Thanks
Regards Tag: How to use backgroupworker to load dataset? Tag: 122636
Brush up my ADO.NET skills
Hi,
I am trying to review by ADO.NET skills so what will be the
best online site to review the topics in ADO.NET and if possible
that should be a future reference to solve some of ADO.NET problems
too.
Thanks Tag: How to use backgroupworker to load dataset? Tag: 122634
sql local database files, need install SQL server on target machine?
New feature come in VS 2005, ability to ADD local database files (.mdf)
into project.
When i install my EXE on client PC, I need install SQL server? Tag: How to use backgroupworker to load dataset? Tag: 122633
Replacement for Com object connect string builder
It used to be that you could add references to the same Com object
used by VS2003 by:
Add ref to [.NET] adodb
Add ref to [COM] Microsoft OLE DB Service Component 1.0 Type Library
Then using ADODB.Connection and MSDASC.DataLinks to access the
dialog for testing connection strings. (ref OReilly book: ADO.NET
Cookbook).
I remember seeing new .NET replacements for this, but can't remember
where.
Anyone? Tag: How to use backgroupworker to load dataset? Tag: 122623
Query on SqlConnection of ADO.NET
Hi,
I have an sql server on seperate system and my application runs on another
dedicated server - both the machines works on Windows 2003 server OS. From
last 2-3 days one of the .net application which has been working fine for the
last 1 year suddently start giving timeout error when querying one of the
tables. Please note that this application could connect to the database
successfully using Windows Authentication. Also there is not much of change
in data volume during the last one week. The machine where the .NET
application runs does not have any SQL instances. It is connecting to the
other server with only SQL server. My query returns around 24000+ rows only -
also both the servers have the best hardware configuration.
My query is that, when we connect to SQL server from .NET application using
data.sqlclient library, does it uses tcp/ip or named pipes for communication
by default ? Is there any way to find this out and change it ? I have used
object viewer to find this out, but could not succeed.
Could some one help ?
Thanks
Suhas Tag: How to use backgroupworker to load dataset? Tag: 122617
Set connection string at run time for typed DataSet (Framework 2.0
I have typed DataSets in a data access tier and want to pass a connection
string from the client at run time (for use by the TableAdapters created
using VS2005). However, at design time, VS2005 sets the connection string as
a property (i.e., serialized to app.config).
This is ok for design time, but at run time, I need to pass the connection
string from the client. Also, I don't want an app.config in my data layer,
and the property that VS creates is read-only, so I don't see a natural way
to set this at run time.
Setting a single static property (similar to what VS does with the
app.config setting) seems like a fine way to keep the connection string, but
I'd like to be able to configure the DataSet (TableAdapters) to use a public
static property that I create instead of forcing me to use app.config.
Am I missing something? Is there a good way to handle this without mucking
around with the code that VS generates for the typed dataset? Tag: How to use backgroupworker to load dataset? Tag: 122611
dataprovider
If I only have ASP.Net 1.1 installed on a server what would I replace this
with?
<dataProvider name="SqlClient"
connectionType="System.Data.SqlClient.SqlConnection, System.Data,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
Thanks Tag: How to use backgroupworker to load dataset? Tag: 122610
quick question: how datareader stores data
Hi,
Where does the datareader store it's data in this scenario:
Create sqlconnection,
Create sqlCommand - query specified here could return 1000 rows
SqlCommand.ExecuteDataReader, returns datareader
use DataReader.read to iterate through the rows.
As far as I understand all the 1000 rows in this case will be initially
brought to the client and consume memory,
they won't stay on the db server and be retrieved one by one with each read.
Is this correct?
Or will they stay on a db server somehow and be retrieved one by one, since
data reader require open connection all the time?
Thank you
Vadim Tag: How to use backgroupworker to load dataset? Tag: 122609
ADO.NET paremeters
Hi everyone. I have a small problem that I can not seem to resolve. I am
executing a stored procedure using the ExecuteReader method. However it is
failing. Here is my code in short. I debugged it using Sql profiler it
appears that my currentdatetime parameter is going to the next line and I am
not sure why, but I am positive that this is the reason it is failing. The
output is below the code.
SqlParameter physID = cmd.Parameters.Add("@phys_id", SqlDbType.Int);
SqlParameter lName = cmd.Parameters.Add("@lname",
SqlDbType.VarChar, 25);
SqlParameter fName = cmd.Parameters.Add("@fname",
SqlDbType.VarChar, 15);
SqlParameter mName = cmd.Parameters.Add("@mname",
SqlDbType.VarChar, 15);
SqlParameter suffixCode =
cmd.Parameters.Add("@suffix_code", SqlDbType.Char, 4);
SqlParameter legalNameInd =
cmd.Parameters.Add("@legal_name_ind", SqlDbType.Char, 1);
SqlParameter insertLogin =
cmd.Parameters.Add("@insert_login", SqlDbType.VarChar, 30);
SqlParameter currentDateTime =
cmd.Parameters.Add("@currentdatetime", SqlDbType.VarChar, 30);
SqlParameter rc = cmd.Parameters.Add("@rc",
SqlDbType.Int);
//Set the parameter values.
physID.Value = physician.PhysId;
lName.Value = physician.LastName;
fName.Value = physician.FirstName;
mName.Value = physician.MidName;
suffixCode.Value = physician.SuffixCode;
legalNameInd.Value = physician.LegalNameInd;
insertLogin.Value = currentUser.Username;
currentDateTime.Value = date;
rc.Value = 0;
rdr = cmd.ExecuteReader();
rdr.Close();
exec phys_names_isp1
@phys_id=34219,@lname='Test4',@fname='Test4',@mname='',@suffix_code=default,@legal_name_ind='Y',@insert_login='kareno_rmf',@currentdatetime='12/27/2005
3:53:43 PM',@rc=0 Tag: How to use backgroupworker to load dataset? Tag: 122601
Using Leave event to trigger an Update in Datagrid
I've often used the datagrid CurrentCellChanged event to trigger my Update
code. However, I've noticed with checkbox columns, this event is not
triggered in the same fashion as with textboxcolumns. So I've been playing
around with the datagrid Leave event to trigger an Update and am curious if
others have any cautionary (or other) advice. Tag: How to use backgroupworker to load dataset? Tag: 122596
Framework 2.0 Changes ADONET 1.1 SqlCommandBuilder Commands
I'm using the SqlCommandBuilder to help construct the update commands to a
SQL Server 2000 database. I have the SqlCommandBuilder generate the initial
command text and then modify the CommandText to use primary keys to specify
the row to be updated.
With the 1.1 Framework on a machine (that also has MSDE 2000 SP3 installed)
the UpdateCommand for a given table begins:
UPDATE tbl_employee SET employee_id = @p1 , purge = @p2 ,
After installing the 2.0 Framework on that machine the UpdateCommand for the
same table is now:
UPDATE [tbl_employee] SET [employee_id] = @p1, [purge] = @p2,
This addition of brackets to the table and field names breaks my existing
code since it is looking for un-bracketed names. After a client installs the
2.0 Framework, my code starts throwing an exception. What is the 2.0
Framework installation doing to modify the SQLCommandBuilder output in the
1.1 Framework and how can I fix it?
Curiously, the order of the installations seems to be important. I installed
the 2.0 Framework before MSDE is ever installed on a machine.
SqlCommandBuilder then returned the desired un-bracketed command string.
However, when I tried to re-install (as opposed to newly install) MSDE over a
2.0 Framework machine, the brackets in table and field names were still in
the command text.
Suggestions?
--
PaulJB PHD Tag: How to use backgroupworker to load dataset? Tag: 122594
loading parent row after child row
Hi, when you load a child row when the parent row doesn't exist in a
relational dataset an execption is thrown.
Is there an event to capture this occurence before the exeption is thrown?
Thanks
Bart Tag: How to use backgroupworker to load dataset? Tag: 122589
How to generate a dataset from stored procedure which have many resultsets?
How to generate a dataset from stored procedure which have many resultsets?
I try Dataset designer from VS2005, it only generate first table from stored
procedure on server explorer. Another table cannot to generate. How should
I do? Tag: How to use backgroupworker to load dataset? Tag: 122587
Recursive Parent keywords in Column Expression
If I have three DataTables, let's call them "MyParentTable", "MyChildTable" &
"MySubChildTable", with a relation between "MyParentTable" and "MyChildTable"
that we'll call "FK_PARENT_CHILD", and a relation between "MyChildTable" and
"MySubChildTable" that we'll call "FK_CHILD_SUB".
If I have an expresion column in the "MySubChildTable" that should access a
column in the "MyChildTable" called "Blargh", then I know I have to write the
expression as "Parent(FK_CHILD_SUB).Blargh" to access that column. But If I
want to access a column in the "MyParentTable" named "Name", how would I
write the expression?
I tried "Parent(FK_CHILD_SUB).Parent(FK_PARENT_CHILD).Name" but that doesn't
work. Is this even possible or do I have to create another expression column
in the "MyChildTable" that accesses the "MyParentTable" table and the "Name"
column? Tag: How to use backgroupworker to load dataset? Tag: 122584
paramaterized Union query?
This is a union query from an Access Database
But I will also be using SQL server
For the meantime in Access,
I want parameters MRN, [GROUP] and SGR
For the following UNION query - (how should I go about this using ADO.NET?)
SELECT 'Inpatient' AS Type, [IN-BNFT] AS Benefit, [IN-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'Outpatient' AS Type, [OUT-BNFT] AS Benefit, [OUT-BFCH] AS
Charge, MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'Ancillary' AS Type, [ANC-BNFT] AS Benefit, [ANC-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'Emergency' AS Type, [EMR-BNFT] AS Benefit, [EMR-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'Drug' AS Type, [DRG-BNFT] AS Benefit, [DRG-BFCH] AS Charge, MRN,
[GROUP], SGR
FROM Membership
UNION
SELECT 'Optical' AS Type, [OPT-BNFT] AS Benefit, [OPT-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'Psych' AS Type, [PSY-BNFT] AS Benefit, [PSY-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'Injection' AS Type, [INJ-BNFT] AS Benefit, [INJ-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'AIDSApp' AS Type, [CAA-BNFT] AS Benefit, [CAA-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'Ext Care' AS Type, [ECF-BNFT] AS Benefit, [ECF-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership
UNION
SELECT 'Claims ER' AS Type, [ERC-BNFT] AS Benefit, [ERC-BFCH] AS Charge,
MRN, [GROUP], SGR
FROM Membership Tag: How to use backgroupworker to load dataset? Tag: 122579
Application settings
Hello
I use the data source window to connect to a database.
Because the location of the database might vary, I want to change the
connectionstring at runtime via my.settings.... but this is an application
setting which can't be changed at runtime.
I know how to accomplish a connectionstring in code, but then I would lose
the advantages of the central data source window.
Do you have a solution for this situation?
Many thanks in advance.
--
Dirk Schelfaut
.NET developper Tag: How to use backgroupworker to load dataset? Tag: 122573
Equivelsnt to old recordset & movenext
Hi,
Is there an equivelant to the old ado recordset which you could use the
movenext/moveprevious methdods with? If not, what do you use to do this in
ADO.NET? What would be the steps invloved in creating the equivelant object &
how do you iterate through the 'record set'? (I'm using c#)
Thanks very much for your thoughts on this. Tag: How to use backgroupworker to load dataset? Tag: 122571
Need some guidance on .NET connection pooling
Hi all,
Merry Christmas!
I have an application that reads records off an Excel spreadsheet and
imports them into an Oracle database.
What I have in my application is a subroutine that opens a database
connection, sets up the command and parameters, and executes a stored
procedure in the database. At the end of the subroutines I close the
connection.
As my application reads through the Excel records (there are about 2000
records), the above subroutine is called, which means the connection opens
and closes for 2000 times.
Is this the correct way to import the 2000 records with connection pooling?
Or am I really supposed to have opened the connection outside that
subroutine, let that subroutine run 2000 times, and then close the
connection? I know this might be a stupid question but as a beginner I
really need an answer...thank you! Tag: How to use backgroupworker to load dataset? Tag: 122568
how to update the database using SqlcommandBuilder
Hi All,
I want to update the values into database.And i get these values
from a xml file.I have done the coding for that but its not getting
updated.Plz tell me whats wrong in my program.if possible provide me
some code for this......
DataSet XMLDataSet = new DataSet();
DataSet SqlDataSet = new DataSet();
DataTable XMLTable= new DataTable();
DataTable SQLTable= new DataTable();
SqlConnection Conn = new SqlConnection("Data source = RPriya; Initial
Catalog = Master; UID = sa; PWD = ");
SqlDataAdapter DataAdapt = new SqlDataAdapter();
DataAdapt.SelectCommand = new SqlCommand("Select * from persondetails",
Conn);
SqlCommandBuilder CommandBuild = new SqlCommandBuilder(DataAdapt);
Conn.Open();
XMLDataSet.ReadXml("d:\\myXmlDocument1.xml");
XMLTable= XMLDataSet.Tables[0];
XMLTable.TableName="persondetails";
DataAdapt.Fill(SqlDataSet, "persondetails");
SQLTable=SqlDataSet.Tables["persondetails"];
SQLTable=XMLTable.Copy();
DataAdapt.Update(SqlDataSet,"persondetails");
Conn.Close();
with regards,
Mohan Tag: How to use backgroupworker to load dataset? Tag: 122550
Multiple database support
How do most people support multiple database types such as SQLServer,
Oracle, Access, etc.? Mainly I am wanting to just support MS (SQLServer and
Access) but may need others in the future.
I am currently looking at creating a simple class that has a few methods for
creating and accessing any database (just an API) and then implementing it
for each DB type I need. Is there a better way?
Thanks Tag: How to use backgroupworker to load dataset? Tag: 122543
Where is my Data Adapter in 2005
I notice that after converting a vs.net 2003 ASP application to vs.net 2005
that my DataAdapters are gone from the design view along with the ability to
enable the Data Adapter Configuration Wizard !!
Surly you are not going to tell me that my Data Adapters can no longer be
maintained (efficiently).
??
--
Regards,
Gary Blakely Tag: How to use backgroupworker to load dataset? Tag: 122541
TableAdapter and Transactions
I saw a lot of people were having a problem with this and I found an
elegent solution to
this problem so I decided to post it.
Use the following Example:
---------------------------------------
private void BindingNavigator_OnSaveItemClick(object sender,
EventArgs e)
{
OleDbConnection Connection = new
OleDbConnection(Properties.Settings.Default.ConnectionString);
OleDbTransaction Transaction = null;
try
{
Connection.Open();
Transaction = Connection.BeginTransaction();
this.SaveClients(Connection, Transaction);
Transaction.Commit();
}
catch (System.Exception ex)
{
MessageBox.Show("An error has occured. Changes will be
rolled back" + "\n" + ex.Message);
Transaction.Rollback();
}
finally
{
Connection.Close();
}
}
private void SaveClients(OleDbConnection Connection,
OleDbTransaction Transaction)
{
try
{
if (clientsTableAdapter.Connection != Connection)
{
clientsTableAdapter.Connection = Connection;
OleDbDataAdapter Adapter =
(OleDbDataAdapter)clientsTableAdapter.GetType().GetProperty("Adapter",
BindingFlags.Instance |
BindingFlags.NonPublic).GetValue(clientsTableAdapter, null);
Adapter.UpdateCommand.Transaction = Transaction;
Adapter.DeleteCommand.Transaction = Transaction;
Adapter.InsertCommand.Transaction = Transaction;
}
this.clientsTableAdapter.Update(Properties.Settings.FastForwardDataSet);
}
catch (System.Data.DBConcurrencyException ex)
{
ClientsConcurrencyManager.ResolveConcurrencyIssue(ex.Row);
this.SaveClients(Connection, Transaction);
}
}
Actually, the only part you need is this:
OleDbDataAdapter Adapter =
(OleDbDataAdapter)clientsTableAdapter.GetType().GetProperty("Adapter",
BindingFlags.Instance |
BindingFlags.NonPublic).GetValue(clientsTableAdapter, null);
NOTE: you should also add "using reflection;" in order for this to
work.
This will give you the Adapter property of the TableAdapter and then
you can do whatever you'd like with it...
no need to write partial classes for all your tableadapters, no need to
worry about code changes done by
Visual studio typed datasets wizard, thank god for reflection!
Works perfect for me!
Jonathan Tag: How to use backgroupworker to load dataset? Tag: 122540
DataColumn.Expression not re-evaluating after a RejectChanges call
Background: Using ADO.NET 2.0 with VS2005 RTM.
I have a data column with the following set for its expression property:
Count(Child(SearchItemCollMmbr).intChildItemID)
I have a Dataset with a parent and child table, linked via a relationship
named SearchItemCollMmbr.
Basically the column shows the number of child rows.
After adding some child rows the count increases as expected.
If the user then cancels what they are doing I call the RejectChanges method
on the dataset to undo their changes. The rows are removed but the parent
table's count of it's child records doesn't change. It is as if the
expression on the DataColumn is not re-evaluated.
Is this a bug or am I doing something wrong. Tag: How to use backgroupworker to load dataset? Tag: 122538
Inheriting from DataGridTextBoxColumn and CancelEdit
I have a combo box that inherits from DataGridTextBoxColumn. Everything
works fine with the control except a CancelEdit(). The underlying rows'
value is rolled back but the DataGrid column still displays the new value
which was cancelled.
Am I missing an event my control needs to receive the cancel?
Thanks for any help,
Joe Tag: How to use backgroupworker to load dataset? Tag: 122534
Create Runtime SQL Query
I have to create an SQL statement at run time based on the items the user
selects on a report menu. The SQL statement gets quite complex if you have
13 menu items each having associated WHERE cretria. I'm using StringBuider to
build the statement
Is there a simple way to create an SQL statement?. Is there a procedural
methodology I should follow when developing the statement? Is there
something free on the web I can maybe pass parameters and it returns a SQL
string? I've already broken the statement into parts. The table,
table.field, AND's and the OR's get real confusing real fast.
Thanks
Steve Tag: How to use backgroupworker to load dataset? Tag: 122524
Connection Pool and Connection time out
Hi all,
i am using Sql Connection with SqlHelper class;
it is working fine with windows xp and MSDE; when i developed the
application and tried it with Sql server200+ windows 2003 it gives Error
message
"The timeout period elapsed prior to obtaining a connection from the pool.
This may have occurred because all pooled connections were in use and max
pool size was reached. "
i have given the MAX pool size =75
i have no clue to this problem , i want to know what is the possible
resoultions
with regards!
Anupam Tag: How to use backgroupworker to load dataset? Tag: 122514
As the existing application is running very slow when start application, How
to use backgroupworker to load dataset?