Making an app run on a local area network.
I realize I have asked this question before and the answer is slowly
becoming clearer but I do not yet quite have it in place. I have a VB.net
application that I have written from a client machine of a local area
network. The LAN has a dedicated file server. The solution is located in a
shared directory of the LAN's file server The drive letter is F. The
application is bound to a SQL Server 2000 database that also resides in a
shared directory on the F drive of the file server.
My application works on the machine I am using but then I have a full blow
copy of VS 2003 installed on the machine. I would like to be able to run
the application from other machines on the local area network. These other
machines all have Windows XP Pro installed and the .net framework.
What do I need to do in order for this to happen? If I understand correctly
I do not have to even worry about creating a .MSI file; I can simply point
the other machines to the .exe file that is created in the Bin directory of
the application that, again, is located in a shared directory of the server.
Is this right? What else do I need to do in order to make (allow) this
application to run from other machines on the Local Area Network? Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90042
Cannot change row in RowUpdating event
Hi,
I had expected to be able to change the DataRow that is passed into the RowUpdating event, but for some reason it does not seem to work. Am I doing something wrong or is a workaround?
--
Thanks in advance,
Juan Dent, M.Sc. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90041
detaching an XmlDataDoc from a DataSet
Hi All,
I've got an XmlDataDocument that is attached to a DataSet with one DataTable
in it. Then I take the XML as text and throw it into a Text Box on a form.
Later on, I wanted to add another DataTable to the DataSet and it
complained:
Cannot add or remove tables from the DataSet once the DataSet is mapped to a
loaded XML document.
How do/can I detach the XMLDataDoc from the DataSet?
Thanks!
Corey. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90040
ADO Shape command to return XML
I'd like to be able to utilize the ADO Shape syntax to return XML.
I've seen examples in MSDN that returns an OLEDB DataReader of this hierarchical data..however I'd like the XML out of it.
I've done this in the previous version of ADO, but I haven't figured out how to do this in ADO.NET. Any insight would be appreciated.
Many thanks-
Dan Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90033
How to create data adapter for multiple tables (joint tables)?
I use sql builder to create a dataadapter. If there is only one table, the
insert/update/delete commands are automatically created successful. However,
if I build a select command based on multiple tables, I got errors:
"insert/update/delete commands can't create automatically for multiple
tables...?". Any of you know how to accomplish this?
Any suggestions are greatly appreciated.
-V Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90023
Query Analyzer speed vs. SqlCommand.ExecuteReader speed
All,
I have an SP that takes about 5 seconds to run before any caching performed by SQL server (I run DBCC DROPCLEANBUFFERS to make sure in my tests).
When I hook the SP into a SqlCommand object, the SP Cmd.ExecuteReader line takes about 5 seconds every time I reload the page. But if I run it through Query Analyzer it takes 5 seconds for the first run and every subsequent request is less than half a second. I assume this is behavior of Sql Server caching the tables/results.
My question is why would Cmd.ExecuteReader take 5 seconds each time if Sql Server is indeed caching teh tables/results (as evidenced by the fast subsequent QA calls)? It is possible there is SET environment variable being called by SqlCommand, or a lack of variable in the connection string that causes the ExecuteReader to take so long each time?
Thanks,
JL Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90022
global connection or seperate connections for each stored proc cal
Hi I seem to recall reading that it can be a bit risky using just 1 global data connection in the global.aspx file, instead of multiple connections, but can not recall why. Also is there a lot of overhead with multiple connections? I did a search but did not find anything. Thanks.
--
Paul G
Software engineer. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90017
sqladapter question
I create the sqladapter programmically.
Dim daInvoice As new sqladapter ("select * from invoice",conMaster)
daInvoice.fill(dsInvoice)
bmInvoice = Me.Bindingcontext(....etc)
Me.txtInvoiceNo.DataBindings.Add("text", dsInvoice,"invoice.invno")
Now, in my add click event. (bmInvoice.addnew())
in my save event.
daInvoice.update(dsInvoice,"Invoice") <-- I got an error here, it said I
need to declare the updatecommand first.
dsInvoice.update()
my invoice got over 50 fields name , DO I need to create 50 parameters in
the commandtext ???
anyshort to update this tables ??
Thanks
From Agnes Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90012
Informix .net provider - Sql server .net provider
Hello everybody
We are currently writting a small app that will be delivered on an Informix
DB and a Sql Server DB. We will be doing some performance check pretty soon
for both databases.
Is anybody using something else other than the IBM informix provider, and
the regular SqlServer provider coming with the .net framework ?
And if so, anybody happy with the ones they chose ?
Regards Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90011
How to know total records selected?
Hello Group,
How can i obtain the total no of records selected with the help of
Datareader class. rowsaffected does not seem to work.
Thanks
Anand Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 90009
System.InvalidCastException
Hi !
First of all, I apologize for my poor english...
I've a cast problem with the code you can find below.
I really don't understand why ?
I'm trying to make a very simple WindowsForm application wich works with the
customers table of the northwind database.
You can find the database hear :
http://www.microsoft.com/downloads/details.aspx?FamilyID=C6661372-8DBE-422B-8676-C632D66C529C&displaylang=EN
There is no problem if you remove this line of code :
Me._dg.TableStyles.AddRange(New System.Windows.Forms.DataGridTableStyle()
{Me._ts})
I just want to populate my DataGrid with the CustomerID (and later the
CompanyName) and using styles seems to be a good way to do this ?
Can every one help me to find what's the problem with my code...?
Any help would be appreciated.
Hervé
**** code ****
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Namespace DefaultNamespace
Public Class MainForm
Inherits System.Windows.Forms.Form
Private _cnx As System.Data.OleDb.OleDbConnection
Private _tbcID As System.Windows.Forms.DataGridTextBoxColumn
Private _ds As System.Data.DataSet
Private _cmdSelect As System.Data.OleDb.OleDbCommand
Private _ts As System.Windows.Forms.DataGridTableStyle
Private _dg As System.Windows.Forms.DataGrid
Private _da As System.Data.OleDb.OleDbDataAdapter
Public Shared Sub Main
Dim fMainForm As New MainForm
fMainForm.ShowDialog()
End Sub
Public Sub New()
MyBase.New
'
' The Me.InitializeComponent call is required for Windows Forms designer
support.
'
Me.InitializeComponent
'
' TODO : Add constructor code after InitializeComponents
'
Me._da.Fill(Me._ds, "Customers" )
End Sub
#Region " Windows Forms Designer generated code "
' This method is required for Windows Forms designer support.
' Do not change the method contents inside the source code editor. The
Forms designer might
' not be able to load this method if it was changed manually.
Private Sub InitializeComponent()
Me._da = New System.Data.OleDb.OleDbDataAdapter
Me._dg = New System.Windows.Forms.DataGrid
Me._ts = New System.Windows.Forms.DataGridTableStyle
Me._cmdSelect = New System.Data.OleDb.OleDbCommand
Me._ds = New System.Data.DataSet
Me._tbcID = New System.Windows.Forms.DataGridTextBoxColumn
Me._cnx = New System.Data.OleDb.OleDbConnection
CType(Me._dg,System.ComponentModel.ISupportInitialize).BeginInit
CType(Me._ds,System.ComponentModel.ISupportInitialize).BeginInit
Me.SuspendLayout
'
'_da
'
Me._da.SelectCommand = Me._cmdSelect
'
'_dg
'
Me._dg.CaptionVisible = false
Me._dg.DataMember = ""
Me._dg.DataSource = Me._ds
Me._dg.Dock = System.Windows.Forms.DockStyle.Left
Me._dg.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me._dg.Location = New System.Drawing.Point(0, 0)
Me._dg.Name = "_dg"
Me._dg.ReadOnly = true
Me._dg.Size = New System.Drawing.Size(204, 418)
Me._dg.TabIndex = 0
Me._dg.TableStyles.AddRange(New System.Windows.Forms.DataGridTableStyle()
{Me._ts})
'
'_ts
'
Me._ts.DataGrid = Me._dg
Me._ts.GridColumnStyles.AddRange(New
System.Windows.Forms.DataGridColumnStyle() {Me._tbcID})
Me._ts.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me._ts.MappingName = "Customers"
Me._ts.ReadOnly = true
'
'_cmdSelect
'
Me._cmdSelect.CommandText = "select * from Customers"
Me._cmdSelect.Connection = Me._cnx
'
'_ds
'
Me._ds.DataSetName = "Customers"
Me._ds.Locale = New System.Globalization.CultureInfo("fr-FR")
'
'_tbcID
'
Me._tbcID.HeaderText = "ID"
Me._tbcID.MappingName = "CustomerID"
Me._tbcID.NullText = " "
Me._tbcID.ReadOnly = true
Me._tbcID.Width = 80
'
'_cnx
'
Me._cnx.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Data
Source=E:\Projets\Customers\bas"& _
"e\Nwind.mdb;Persist Security Info=True"
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(564, 418)
Me.Controls.Add(Me._dg)
Me.Name = "MainForm"
Me.Text = "MainForm"
CType(Me._dg,System.ComponentModel.ISupportInitialize).EndInit
CType(Me._ds,System.ComponentModel.ISupportInitialize).EndInit
Me.ResumeLayout(false)
End Sub
#End Region
End Class
End Namespace Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89998
Common DataSource gives unexpected behavior with comboboxes
When I have 2 comboboxes whos datasource is the same datatable I get some unexpected (and unwanted) behavior. When I change the selection in either combobox, the other changes to match it. The behavior probably applies to other controls as well.
I would guess binding is being overly helpful, but I need to know how to disable it.
I've considered just making of copy of my datatable for one of the controls, but I doubt that is the proper solution. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89991
Make data available to Excel, Access, ...
Hi,
sorry for the cross post, but don't know which of both groups would be the
best one.
I have implemented a .Net DataReader and DataAdapter for our custom data and
it works fine so far. Now I want to make the data available to Excel,
Access, ... One solution would be to develop a OLEDB Provider in C++ via ATL
Templates. But I wonder if there is a simpler way!? Can I develop a OLEDB
Provider in C#? Or is there a mapping between OLEDB and .Net Datasources?
regards,
Achim Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89987
is there a performance benefit when using Prepare() on command that
Hi,
I was just reading the book "ADO.NET in a Nutshell".
In the chapter on the Command-Object (p. 36) it reads:
"A parameterized command won't improve performance as compared to the
original dynamic SQL statement. Unlike a stored procedure, a
parameterized query isn't stored in the database and isn't precompiled.
The difference is simply one of syntax."
OK. Sounds plausible to me. But i recalled reading something different
to that on MSDN. The article "Best Practices for Using ADO.NET"
(http://msdn.microsoft.com/library/en-us/dnadonet/html/adonetbest.asp?frame=true#adonetbest_topic4)
includes the following:
"The Command.Prepare method can improve the performance of parameterized
commands that are repeated at your data source. Prepare instructs the
data source to optimize the specified command for multiple calls. To use
Prepare effectively, you need to thoroughly understand how your data
source responds to the Prepare call. For some data sources such as SQL
Server 2000, commands are implicitly optimized and a call to Prepare is
unnecessary. For other data sources such as SQL Server 7.0, Prepare can
be effective."
So, who is right? Or am I just getting something wrong and mixed up?
Is the effect of the Prepare()-call specific to the data source?
Does it only work with SPs or also with plain SQL-Text?
Any help will be greatly appreciated.
Thanks in advance,
Lorenz Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89985
Inserting Nulls into a Dataset
Hi
I have a simple table which allows nulls. Using a Dataset I have added a new
rows to the table specifying the values for the columns I have and leaving
the others.
When I come to run the update command via the dataadapter the insert stored
procedure fails because the parameters corresponding to the null fields in
the dataset and not supplied. How do I get round this?
Regards Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89984
RE: SQLCE Problem on Create Table
*The code is below. It always stuck on line "command4.ExecuteNonQuery()" and
it throws an Sqlce exception
Under Public Class Form1 definition:
Private Const filename4 As String = "MUSTERI.SDF"
Private connstr4 As String = String.Format("Datasource={0};Password={1}",
filename4, "Admin")
Private connection4 As SqlCeConnection
Under Private sub CreateDB Click():
Dim engine4 As New SqlCeEngine(connstr4)
If Not File.Exists(filename4) Then
engine4.CreateDatabase()
Else
MsgBox("FILE EXISTS")
End If
engine4.Dispose()
connection4 = New SqlCeConnection(connstr4)
connection4.Open()
Dim command4 As SqlCeCommand = connection4.CreateCommand
command4.CommandText = "CREATE TABLE MUSTERI (INDEXMS nvarchar(5),MSAD
nvarchar(30),MSSOYAD nvarchar(30),MSSEMT nvarchar(30),MSSEMTRCH
nvarchar(30),MSTLF nvarchar(15),FIYAT nvarchar(3),INDEXBY
nvarchar(4),VHMARKA nvarchar(30),VHMODEL nvarchar(50),VHLSEBAT
nvarchar(20),VHYIL nvarchar(4),LASONMRK nvarchar(20),LASONDSN
nvarchar(30),LASRKMRK nvarchar(20),LASRKDSN nvarchar(30),VHDSSGON
nvarchar(10),VHDSSGRK nvarchar(10),VHDSSLON nvarchar(10),VHDISSLRK
nvarchar(10),VHPLAKA nvarchar(15),VHIDHVON nvarchar(3),VHIDHVRK
nvarchar(3),TARIH nvarchar(10),USER nvarchar(5))"
command4.ExecuteNonQuery()
command4.Dispose()
MsgBox("MUSTERI.SDF TAMAM")
' 4TH Creation Complete
connection4.Close()
"Enver A" <ea90@hotmail.com> wrote in message
news:%23r8xTZhUEHA.2484@TK2MSFTNGP11.phx.gbl...
> Hey ppl,
> I am having trouble in building a smart device application. I cant create
a
> table on SQLCE server using this line. Anyone can tell me what the problem
> is?
> I am able to create another 3 Tables same way but this SQL line is always
> gives me problems.
>
>
> command4.CommandText = "CREATE TABLE MUSTERI (INDEXMS nvarchar(5),MSAD
> nvarchar(30),MSSOYAD nvarchar(30),MSSEMT nvarchar(30),MSSEMTRCH
> nvarchar(30),MSTLF nvarchar(15),FIYAT nvarchar(3),INDEXBY
> nvarchar(4),VHMARKA nvarchar(30),VHMODEL nvarchar(50),VHLSEBAT
> nvarchar(20),VHYIL nvarchar(4),LASONMRK nvarchar(20),LASONDSN
> nvarchar(30),LASRKMRK nvarchar(20),LASRKDSN nvarchar(30),VHDSSGON
> nvarchar(10),VHDSSGRK nvarchar(10),VHDSSLON nvarchar(10),VHDISSLRK
> nvarchar(10),VHPLAKA nvarchar(15),VHIDHVON nvarchar(3),VHIDHVRK
> nvarchar(3),TARIH nvarchar(10),USER nvarchar(5))"
>
> Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89980
Create DataSet from ArrayList
How can I create a dataset from an arraylist? I thought I could fill a
dataset using an arraylist as the datasource but I can't find the way to do
this?
Wayne Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89976
Insert SQL statements into a DB record using Command object?
Hello,
I'm porting a VB6 / ADO application to VB/ADO.net and I'm running into
some ADO.Net problems.
I have a system that allows users to write and test their own SQL
statements, and then save them to the SQL Server in a table called
AdHoc.
(They are not allowed to use certain destructive statements such as
DROP, DELETE)
When they are happy with the results of the query, they save the SQL,
and a short menu text into the database. They can then select and run
the query they created by choosing it from a combo box (using the menu
text).
This was never a problem in ado classic, but when I use an ADO.net
command object and call the .ExecuteNoneQuery method, it seems that
the SQL statements I want to add or update in the database, are
getting mixed up in the SQL Insert or Update statements that actually
do the saving/updating of the database.
So I guess my question is: how can I execute an SQL statement that has
string fields, that contain SQL statements themselves.
Anyone?
ss. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89972
reflexive relation in dataset
Hi all,
I've got the following problem:
I need to describe a tree structure, the table in the dataset consists
of the columns structID, parentStructID, description with structID as
primary key.
the parentStructID of a root treenode is DBNull.
I define a reflexive 1:n relationship from treestructID to
parentTreeStructID.
loading the the database table into my dataset produces an error,
because the DBNull-value of my root tree node violates my DataSet
relation (but not the relation defined in my database, anyway).
common solution is: setting the nested-property of the DataRelation in
my DataSet to true. that works fine, so far so good.
here's the heart of the problem:
setting the nested property to true in VS2003 dataset desginer lets the
code generator forget my relation. that means if I instanciate my
dataset the relation collection remains empty.
if I set the nested property to default or false the relation will be
generated and I have access from code.
accessing and setting the nested property of my DataRelation to true
produces the result I need and everything works fine.
so what's wrong? the designer's handling of relationships or my
understanding of the designer? or do I miss to set a further property?
tia,
Thorsten Kallweit Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89970
How to hide ID & password in RDS object definition
Can I hide Id & Password in ASP page for RDS object definition?
My RDS object is as below:
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDS>
<PARAM NAME="SQL" VALUE="Select command...">
<PARAM NAME="SERVER" VALUE="http://server name">
<PARAM NAME="CONNECT" VALUE="Provider='sqloledb';user id=id123;password=pass123;Initial Catalog=db123">
</OBJECT>
Thnaks in advance.
p.dev Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89965
databinding textboxes
ive bound textboxes in design and in code.
changes to the textboxes are reflected in the dataset, however, such changes do not get updated in the database. i have no problem with updating datagrids etc..
please advise...
thanks Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89963
constraints from a dataset to a database
Hi,
I have a typed dataset that was once create from a database. As time
passed, we'd lost the original database, and had to recreate it.
However, we don't want manually to recreate the constraints also -
they are in the dataset.
Is there a way to automatically bring the constraints from the dataset
into the SQL database ?
Alex. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89962
checking if the dataset is empty?
HI There,
How can I check if the dataset is empty? I just want to check to see if the
dataset is empty or null when the query is run, couls someone help me out
with some code please?
Sean
Function getTheData(ByVal CategoryID as Integer) As DataTable
Dim DS As New DataSet()
Dim strConnect As New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
Dim objSQLAdapter As New SQLDataAdapter("SELECT L.manufacturer,
L.modeldesc, L.listprice,G.Location FROM tblListings L INNER JOIN tbLocation
G ON L.location = G.LocationID WHERE formid=" & CategoryID, strConnect)
objSQLAdapter.Fill(DS, "tblListings")
Return DS.Tables("tblListings").Copy
End Function
Sub doPaging(ByRef CategoryID)
pagedData.DataSource = getTheData(CategoryID).DefaultView
pagedData.AllowPaging = True
pagedData.PageSize = 10
Try
pagedData.CurrentPageIndex =
Int32.Parse(Request.QueryString("Page")).ToString()
Catch ex As Exception
pagedData.CurrentPageIndex = 0
End Try
btnPrev.Visible = ( NOT pagedData.IsFirstPage )
btnNext.Visible = ( NOT pagedData.IsLastPage )
pageNumber.Text = (pagedData.CurrentPageIndex + 1) & " of " &
pagedData.PageCount
theDataList.DataSource = pagedData
theDataList.DataBind()
End Sub Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89959
Update failure
Error message: Argument 'Prompt' cannot be converted to type 'String' when I try to update a dataset.
Try
OleDbDataAdapter1.Update(ds, "PatientSummaryTBL")
Catch e As Exception
MsgBox(e)
End Try
much Appreciated Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89958
Format currency in datalist items?
HI There,
I was wondering if you can format currency values in a datalist? I have
tried many ddiiferent ways to do this and all have given me errors.
Sean - thanks in advance
<%# DataBinder.Eval(Container.DataItem, "listprice")%>
DataFormatString="{0:$#,###.##}" Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89957
Problem with Dataset for MS Access Yes/No Field
Hello All!
I have some problem with Yes/No field in MS Access.
In WebService I create DataSet and return it client like next:
DataSet ds = new DataSet( );
daContentList = new OdbcDataAdapter( mysection.SelectRequest,
( string )ConfigurationSettings.AppSettings[ "ConnectionString" ]
);
OdbcCommandBuilder cbContentList = new OdbcCommandBuilder(
daContentList );
if( mysection.TableName.Equals( string.Empty ) ){
daContentList.FillSchema( ds, SchemaType.Source, sName );
daContentList.Fill( ds, sName );
}else{
daContentList.FillSchema( ds, SchemaType.Source, mysection.TableName
);
daContentList.Fill( ds, mysection.TableName );
}
ds.DataSetName = sName;
return ds;
The code worked perfectly but Schema is incorrect in some places for
example for all xs:string, xs:int alements schema allowed
minOccurs="0" and for all bit fields xs:boolean minOccurs="1". This
behaviour is incorrect cause I have some mondatory Text fields and all
bit fields are optional
What's wrong with my schema for dataset?
Thanks Alex Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89955
Threaded application, DataTables and DataGrids
Hi,
I'm novice with C# and have a little problem in my current project.
I'm updating some DataTable from different Thread. There's no problem to update the DB, but adding new records freeze the application because I've a datagrid showing the updates in realtime...
Principe :
myDataGrid.DataSource = new DataView(myDataTable);
After a lot of tests, it appears to be the fact of new rows created in another thread.
What can I do to go through this? Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89949
hyperlinks with querystring values in a datagrid
Hi There,
I was wondering how I can have a hyperlink with a querystring value in a
datagrid? Could someone help me with an example please?
Sean - thanks in advance
<columns>
<asp:BoundColumn HeaderText="Make & Model" DataField="modeldesc" />
<asp:BoundColumn HeaderText="ID" DataField="modelID" />
<asp:BoundColumn HeaderText="listprice" DataField="listprice"
ItemStyle-HorizontalAlign="Right"
DataFormatString="{0:$#,###.##}" />
</columns> Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89947
default values
It's MS Access database. Some table has a fields with default values, for
example, =Date().
But when I adding a row in DataGrid - the default values not displayed. If I
not fill this fields and then update dataset - in database all records added
via DataGrid - without default values.
How can I resolve this problem and default values displays in DataGrid?
Thanks.
--
Stanislaw Tristan
Kyiv, Ukraine
E-mail: stas7775@i.com.ua Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89944
How to create a new table in SQL Server using DataTable
Hello,
Is it possible to write a DataTable to SQL Server.
I would like to create new DataTable with some columns and records. Now I would like to store this DataTable to SQL Server as a new Table.
Can someone let me know if this possible?.
Thanks
--
Rajiv Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89943
Program crashes when network goes down and back up
I could definitely use some help with this error! My VB.NET 2003
program only connects to the database when the user saves, retrieves,
etc. If they retrieve a file from the database to work on, and the
network goes down for more than about ten seconds and comes back up,
the next time they try to save the program crashes on the first line
of code that talks to the db. Actually it gets as far as opening the
connection, but breaks on this line: objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection) with this
error:
A first chance exception of type 'System.Data.SqlClient.SqlException'
occurred in system.data.dll
Additional information: System error.
The exception's error message is usually: General network error.
Check your network documentation.
I don't understand! It seems to me that if the network goes down and
comes back up while the program is running but not using the database,
then it should not cause any problems. Any ideas?
Thanks!
Kevin Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89941
Update data without SQL statement
I want to update a table without using a sql statement.
I am hoping for something similar to ado update.
ds.Tables[0].Rows[x] ["authorid"] = "Rick"
ds.update
is something like this possible?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89939
Should I use additional SQL Queries or use FindRows
Hi all, currently my application generates a DataSet object from a query issued to the database.
Then it uses some of the values from that DataSet object to send off further queries and so on.
However, I'm starting to wonder if it might be more efficient to use the "FindRows" method or RowFilter property on a DataView instead of issuing further queries.
Basically, I could retrieve all of the data into my DataSet and then create DataViews on that DataSet to do what I'm currently doing with a number of SQL queries.
However, the values I'm retrieving from the DataSet do not belong to any of the indices (primary key or otherwise) that I have built on the database tables. So it looks like I will have to use the "Sort" method before I can use the FindRows method.
Besides which, I don't know how to FindRows with the Null value (I'm guessing I just put Nothing as the object parameter). This is the code I've tried to use:
Dim myView As DataView
myView = myDataSet.Tables("some_table").DefaultView()
myView.Sort() = "column_in_table"
myView.FindRows(System.DBNull)
If I use the above code, I get the error:
Expecting 1 value(s) for the key being indexed, but received 0 value(s).
I'm guessing I need to be using "System.DBNull" somehow but I'm not sure how.
Or should I be using the RowFilter property:
myView.RowFilter = "column_in_table = NULL"
However, if I do it using the RowFilter I don't know how to generate the array of DataRowView objects. I need this since I'm not directly binding this data to a web control.
To summarize:
1. How should one determine whether it is more efficient to navigate data by issuing a SQL query for each step or whether it is more efficient to use the RowFilter property or FindRows method?
2. How can you use the FindRows method to find rows where an attribute/value in a column is set to NULL?
3. How can you get the array of DataRowObjects once you set the RowFilter property to the query string of your choosing?
Thanks,
Novice Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89938
Typed DataSet problem - Re-posted
Two DataSets loaded with the same XML data and schema write two different XML data files. Bellow youâ??ll find a simple test code and the output.
Declare, instantiate and load the DataSets:
Dim dsOrig As New DataSet("Request")
Dim dsDup As New DataSet("Request")
Dim filePath As String
filePath = " PVIrequest.xml"
dsOrig.ReadXml(filePath)
dsOrig.WriteXmlSchema("Test.xsd")
dsDup.ReadXmlSchema("Test.xsd")
dsDup.ReadXml(filePath)
Edit the first DataSet and Write XML:
Dim swXML As New System.IO.StringWriter
With dsOrig
Dim rwEdit As DataRow
rwEdit = .Tables("eCommerce").Rows(0)
rwEdit.BeginEdit()
rwEdit("action") = "Test"
rwEdit.EndEdit()
.WriteXml(swXML)
TextBox1.Text = swXML.ToString â??See bellow
<eCommerce version="1.1" action="Test"><Requestor><ID>value</ID><Password>*******</Password></Requestor><Shipment action="GenerateLabel" version="1.0">
Complex Type data
</Shipment></eCommerce>
Edit the second DataSet and Write XML:
Dim swXML As New System.IO.StringWriter
With dsDup
Dim rwEdit As DataRow
rwEdit = .Tables("eCommerce").Rows(0)
rwEdit.BeginEdit()
rwEdit("action") = "Test"
rwEdit.EndEdit()
.WriteXml(swXML)
TextBox1.Text = swXML.ToString â??See bellow
<Request><eCommerce version="1.1" action="Test"><Requestor><ID>PENTA_0608</ID><Password>57ID57C7UH</Password></Requestor><Shipment action="GenerateLabel" version="1.0">
Complex Type data
</eCommerce></Request>
I need to get rid of the extra tags (the DataSet name).
I thank Cowboy for his Xml Transform suggestion, but I would like to know what am I missing with my approach?
As I mentioned in my previous cry for help, my way around it was to create doc as an XmlDataDocument(dsDup) and call doc.SelectSingleNode("/Request") function.
I hope that this message has clarified my problem.
Thank you. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89931
Xml Schema Relations
When I bring an existing schema into the XML designer, right-clicking the relation object (grey square) doesn't allow me to select Edit Relation.
Same with XML Schema toolbar. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89930
How do I mark a DataTable as read-only
I want to return a read-only DataTable so that I can cache it. Is it
possible?
Alternate suggestions (that don't waste tonnes of memory)?
Thanks,
Philippe Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89929
connection in connection pool with pooling=false
I'm finding that even when pooling=false, a connection remains in my
connection pool connected to my database (it seems to quite quickly timeout
though - say 30 seconds).
My connection string:
Initial Catalog=Benji_UnitTest;Data Source=.;Integrated
Security=SSPI;Pooling=false
Using this setting, I would expect that a new connection be created
everytime, and that when the SqlConnection is close()'d (i.e., returned to
the "pool") that the underlying database connection would be closed.
I also tried setting ";Connection Lifetime=1" in order to get the connection
to close quickly (as a worksround); this didn't seem to affect any change.
Am I misunderstanding something?
Thanks,
j Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89919
Arjen Jongeling, een oude bekende
Hoewel, Arjen Jongeling is hier nog nooit geweest en ik denk dat Arjen Jongeling hier ook nooit meer zal terugkomen. Sterker nog, Arjen Jongeling zit hier helemaal fout. Maar ja, het doet het goed in de Google archieven. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89918
how to delete a connection pool?
Is there a way that a connection pool can be explicitly deleted? E.g., using
the connection string, call some method that will close all the connections
in the pool?
Is there anyway to achieve this?
j Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89917
sql data reader issue.
I have the following code:
Public Sub SelectAdminUserByID()
Try
Dim oDR As SqlDataReader =
oData.ExecuteReader(sConnectionString, CommandType.StoredProcedure,
"spSelectAdminUserByID")
'If oDR.HasRows Then
Do While oDR.Read()
Username = CType(oDR.Item("Username"), String)
Password = CType(oDR.Item("Password"), String)
Active = CType(oDR.Item("Active"), Boolean)
Loop
'End If
oDR.Close()
oDR = Nothing
oData = Nothing
Catch ex As Exception
End Try
End Sub
I am getting a "Object reference not set to an instance of an object."
error. It is bombing on the first reference to oDR. Can someone
please point out the problem here.
Thanks Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89912
leaf rowstate unchanged on DataAdapter.update
Hello everybody
when I use the update method of a DataAdapter all added rowstates get
change. How can I make the DataAdapter let the rowstate unchanged, like the
AcceptChangesDuringFill property when filling.
Thank you
Anton Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89911
Batch Datatable Updates
Hi all,
Further to my last post regarding batch datatable updates, it seems that
loaddatarow ignores rows that are not in the "unchanged" state.
Whats the best way of dealing with this? I need to be able to add rows that
I dont know in advance whether they exist or not. After updating, I need the
rowstate to be correct too, since that would be what is used to send the
updates/inserts to the database.
Do I manually select based on PK values, and then edit/add as necessary?
Does select also ignore non "unchanged" values? If so, how do I get to
these?
This seems like a useful facility so why is loaddatarow designed to ignore
added rows?
Spammy Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89910
Deadlock Handling
Hi,
I have written an application that recently, under heavy load,
encountered the deadlock. After considering the time issue, I decided
to live with them. However, I have trouble reproducing them in order
to trap and handle them properly. Could someone please tell me what's
the Number it returned in the SQLException object so that my following
exception handling code would work?
Q1: Is the Number = 1025 or 10255 for deadlock?
Q2: Is 1 second a good interval for the victim to wait before retry?
While completed = false
Try
commit transaction
success = true
Catch SQLDeadlock As SQLException
If ErrorCount < RetryCount Then
For ErrorIndex = 0 To SQLDeadlock.Errors.Count
// catch deadlock, no need to roll back for it's handled by
DB
If SQLDeadLock.Errors(ErrorIndex).Number = 10255 Then
System.Threading.Thread.Sleep(1000)
LogErrorEvent(...)
Else
// catch other sql exceptions and roll back transaction
roll back transaction
LogErrorEvent(...)
End If
Next
Else
LogErrorEvent(...)
Exit While
End If
Catch ex As Exception
MsgBox(ex.tostring)
Finally
If success Then
complete = true
dispose transaction
else
ErrorCount += 1
end if
End Try
End While
Thank you for your help.
Charlie Chang
charlies224@hotmail.com Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89909
Transaction Question
Hi,
Can someone explain to me how the transaction object works behind the
scenes? I am currently using it in my updates and it works great. I was
curious how the rollback works and the update (added, modified and deleted
rows) actually are changed at the time of call to the dataadapter or when I
commit the changes?
Thanks Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89903
Confusion regarding loaddatarow and update
Hi all,
Im using a SQLDataAdapter with custom select, update and insertqueries which
i assume work (as they are simple SQL statements).
I use this adapter to fill a table. I also add a few more columns, and set
up primary keys. I make updates to this table. I do this by queuing the data
to be added up, and then calling beginloaddata, loaddatarow per queue item,
and finally endloaddata. I then call update on the datatable to send these
updates to the database. Unfortunately Im not getting the behavior I expect.
My understanding of loaddatarow was that it uses the primary key values to
determine if a row exists to amend - if not then it creates the row instead.
However, this only seems to happen if you set the acceptchanges argument on
loaddatarow to true. If I do this, however, then the table seems to forget
which were the new/changed rows (while debugging the status of the row reads
"unchanged") and so no updates get sent.
If I set this flag to false then endloaddata throws an exception since I may
have added two rows with the same primary keys (when what I really want to
do is update a row that may have already been newly added in this batch of
loaddatarow calls, if you see what I mean).
Is my understanding of this incorrect?
Spammy Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89901
dataReader returns an error if field blank
Hey there
I know there's a simple answer to this Quesiton because I've asked it before (but I have not yet used it and have now forgotten what the answer was!) so..
I have a simple Datareader returning the value of a field from a SQL Server but if the field is blank, the application returns an error.
A piece of the code is as follows:
cmd = New SqlCommand("SELECT * FROM thisTable WHERE Email = '" & memberVariable & "'", cn)
rdr = cmd.ExecuteReader()
rdr.Read()
textField1.Text = rdr("column1")
textField2.Text = rdr("column2")
I remember the solution was something like
textField2.Text = rdr("column2") & ""
but this returns the same error.
Help! Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89880
display images from SQL server in datareader
Hi There,
I am trying to display some images from SQL Server, the image is displaying
correctly, but when I have more than one row in the table I only get one
image displayed? What am I doing wrong? is there a better way to do this?
Sean - thanks in advance
<%@ Page Language="vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<HTML>
<HEAD>
<title>Retrieving Image from the Sql Server</title>
<script runat=server>
Public Sub Page_Load(sender As Object, e As
EventArgs)
Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As New SqlCommand("Select
ListingImage,ListingImageType from tblListings", myConnection)
Try
myConnection.Open()
Dim myDataReader as
SqlDataReader
myDataReader =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Do While
(myDataReader.Read())
'Dim bindata() As
Byte = myDataReader.Item("ListingImage")
'Response.BinaryWrite(bindata)
Response.BinaryWrite(myDataReader.Item("ListingImage"))
'Response.BinaryWrite(myDataReader.Item("ListingImageType"))
Loop
myConnection.Close()
Response.Write("image
displayed")
Catch SQLexc As SqlException
Response.Write("Read Failed
: " & SQLexc.ToString())
End Try
End Sub
</script>
</HEAD>
<body style="font: 10pt verdana">
</body>
</HTML> Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89879
Inserting Images into SQL Server
HI There,
I am trying to insert images into SQL server with ADO.net, the images are
inserted without any problems, but on some occasions there will be no image
to insert. Can I replace the empty value with a default image to insert? or
any image residing on the file system?
Sean - Thanks in advance
intImageSize = Trim(ListImage.PostedFile.ContentLength)
strImageType = ListImage.PostedFile.ContentType
ImageStream = ListImage.PostedFile.InputStream
if Not ImageContent Is "image/gif" OR ImageContent Is "image/pjpeg" Then
Else
ImageContent = "C:\Documents and
Settings\Administrator\Desktop\kamt1bkat.jpg"
End If
'image
Dim plistingImage As New SqlParameter("@ListingImage", SqlDbType.Image)
plistingImage.Value = ImageContent
myCommand.Parameters.Add(plistingImage)
'image type
Dim plistingImageType As New SqlParameter("@ListingImageType",
SqlDbType.Nchar, 200)
plistingImageType.Value = strImageType
myCommand.Parameters.Add(plistingImageType) Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89878
Sheet names in Excel
I appreciate everyone's help with my connection string for Excel. Here's a
follow-up or two.
How do you get the sheet names from Excel if you don't know them in advance
for your SELECT statement?
Also, is there a connection string that specifies no header row? HDR=NO
causes a "No installable ISAM" error.
Thanks. Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89877
convert DbType to/from TypeCode
I can find plenty of documentation on the relation between
System.Data.DbType and System.Type e.g.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconmappingnetdataproviderdatatypestonetframeworkdatatypes.asp
Is there a method anywhere in the .NET framework that does this mapping, or
do we have to write a long switch(...) statement? Tag: Het zal toch niet zijn wie ik denk dat het is? Tag: 89873
Is het die Ear Youth weer? Nee, het is Arjen Jongeling!
Het is een kwestie van geduld
voor heel usenet Hollands lult