ADO.NET EntityFramework and Large SQL Databases
Hello.
This is my scenario. I am building a WinForm app. I have a 300+ tables
databases.
My problem comes everytime i have to build my app. it takes forever and i
guess the reason is that everytime that i compile, the system is compiling
the 300+ entities it just created. i found a bizarre solution to my problem
by having another project, a class library project, only for the model. Then
i unchecked the Build in the Solution properties so it doesn't get built all
the time. That's fine, but for some reason, i cant find the provider class
and also i am having other issues. i guess my question is... Is there a
DESCENT way to have the Entity model co-existing in peace in my Winform
project and do not wait up to 2 minutes everytime i need to build my app
(which happens about 300 times a day in test phase)
Any hint on this would be higly appreciated Tag: http://cbt.googletoad.com | Free training Videos Tag: 145637
how to identify the OleDb exception without relying on its message
I have written the code that allows to work with a password protected
Microsoft Access database as well as with regular (not password protected)
Access DB in VB. Net. I use OleDb objects. I need to identify whether a
current database is password protected, or not. For this purpose, I create a
regular connection string with no password set, and try to open the
connection. This piece of code is embedded into Try..Catch.. structure. If a
database is password protected, an OleDb exception is raised, with the
message "Not a valid password". To determine what is the reason of failure to
open a connection, I test the message property of the exception. If it
contains the string "Not a valid password", then I can conclude that the
database is password protected.
This code worked fine until we shipped our software to Netherland. I have
found that the message is now "Geen geldig watchwoord", and my code stopped
working.
The question 1: is there a way to identify the particular exception by an
universal attribute (like Error number) without relying onto its message
(which looks different in localized versions of OS)?
The question 2: is there an alternative way to find whether a Microsoft
Access database is password protected?
Thanks
Igor Tag: http://cbt.googletoad.com | Free training Videos Tag: 145636
.net hold query results?
Hello, friends,
We have a windows service which will query database through a web service
every one minute. If there are new records, this windows service will process
accordingly.
However, if there are no new records for a long time, say 2 days in weekend,
this windows service will no longer be able to retrieve new records anymore.
Although it still does the query, but return no records.
We then have to stop and restart this windows service to make it work again.
We believe .net hold query results somewhere, probably in web service.
Rather than actually going to the database to query again, it just returns
whatever cached in memory.
Are we right, and how to solve this problem?
Thanks a lot. Tag: http://cbt.googletoad.com | Free training Videos Tag: 145632
Always prompted to save when any Row is Modified
Hello, i have a problem relatrive to DataRowState.Unchanged, i have
the bellow code in my Save Button called by BSModificada()
'IF ANY CHANGE SaveData()
Private Sub BSModificada()
Me.Validate()
Me.TABMAINBindingSource.EndEdit()
Dim vDR As DataRow =3D CType(Me.TABMAINBindingSource.Current,
DataRowView).Row
If vDR.RowState <> DataRowState.Unchanged Then
SaveData()
End If
End Sub
'IF Added or Modifyed Update
Private Sub SaveData()
Try
Dim vvDR As DataRow =3D
CType(Me.TABMAINBindingSource.Current, DataRowView).Row
If vvDR.RowState =3D DataRowState.Detached Then
DBAdiciona()
ElseIf vvDR.RowState =3D DataRowState.Modified Then
DBModifica()
End If
Catch ex As Exception
clsUtilidades.ShowError(ex.Message, ex.ToString)
End Try
End Sub
In DBAdiciona() and DBModifica() i am always Accepting Changes by
Me.ESTDataSet.TAB_MAIN.AcceptChanges().
This code works good, until i try to see if any Change made when
closing the form, i am always prompted to save when any Row is
Modified even i click the save button and Accepting the Dataset
Changes, the code bellow on Form Closing
Private Sub frmEstatisticaMensal_FormClosing(ByVal sender As Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
Me.FormClosing
Me.Validate()
Me.TABMAINBindingSource.EndEdit()
Dim vvvDR As DataRow =3D CType(Me.TABMAINBindingSource.Current,
DataRowView).Row
If vvvDR.RowState <> DataRowState.Unchanged Then
If MessageBox.Show("Altera=E7=F5es detectadas, quer gravar?",
"", MessageBoxButtons.YesNo, MessageBoxIcon.Question) =3D
Windows.Forms.DialogResult.Yes Then
e.Cancel =3D True
SaveData()
Else
e.Cancel =3D False
End If
End If
End Sub
Thanks for your time, any help will be welcome
Joao Tag: http://cbt.googletoad.com | Free training Videos Tag: 145629
"Database" missing in VS C++ 2008 CLR Windows Forms Application
In a Visual Studio 2008 C++ CLR Windows Forms Application, there is only
an "Object" icon, but no "Database" icon after
Data|Add New Data Source
In a Visual Studio 2005 C++ CLR Windows Forms Application as well as in
a Visual Studio 2008 C# CLR Windows Forms Application, a "Database" icon
is shown.
What do I have to do get this icon in a C++ CLR Windows Forms
Application to create a DataSet?
Thanks
Richard Tag: http://cbt.googletoad.com | Free training Videos Tag: 145628
LINQ Where 1=0
I have a asp.net gridview with a LinqDatasource.
When I do a delete the SQL profiler shows
DELETE FROM [dbo].[UsersInRoles] WHERE 0 = 1
The exception is:
[System.Data.Linq.ChangeConflictException] = {"Row not found or changed."}
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
onselecting="LinqDataSource1_Selecting"
ContextTypeName="ApplicationManagment.ApplicationsDataContext"
TableName="UsersInRoles" StoreOriginalValuesInViewState="False"
EnableDelete="True" EnableInsert="True" EnableUpdate="True">
</asp:LinqDataSource>
<cwp:GridView_Ex ID="gvUserInRoles" runat="server"
AutoGenerateColumns="False"
DataKeyNames="UsersInRolesID" DataSourceID="LinqDataSource1"
CanDeleteRows="True" CanEditRows="True"
>
In the datasource_selecting event I have:
ApplicationsDataContext ctx = new
ApplicationsDataContext(ConfigurationManager.ConnectionStrings["cnnApplicationManagement"].ConnectionString);
int[] iqueryAuthorizedApplications =
queryAuthorizedApplications.ToArray();
var queryRoles =
from
u in ctx.UsersInRoles
where
//get authorized and Filtered applications
iqueryAuthorizedApplications.Contains(u.ApplicationID)
&& //filter active
(chkActiveOnly.Checked == false ||
u.ApplicationRole.Application.DateRetired == null)
&& //filter application ddl
(ddlApplications.SelectedValue == "-1" ||
u.ApplicationID.ToString() == ddlApplications.SelectedValue)
&&
u.ApplicationRole.lutRole.IsPublicRole == true
&& // filter roles
(ddlRoles.SelectedValue == "-1" || u.RoleID.ToString() ==
ddlRoles.SelectedValue)
&& //filter Zno
(txtUser.Text == string.Empty || u.UserZno == txtUser.Text)
select u;
e.Result = queryRoles;
I saw in Scott G. Blog you can do this in the event and still have deleting.
How should I debug this?
In the exception handler I don't have access to the DataContext. Is their a
way to get the DataContext from GridViewDeletedEventArgs or the DataSource?
That way I could enumerate the context.ChangeConflicts. Tag: http://cbt.googletoad.com | Free training Videos Tag: 145626
Add Connection Dialog box
I'm using VB 2005 Express and am trying to set up a new SQL Server
connection using another server on my network. My problem is when I go to
set up a new connection and the Choose Data Source dialog box comes up only
MS Access and SQL Server database file choices are there. I'm stumped as to
how to address this limitation. I can connect and do what I need through
ADO. Net to any server but cannot set a persistent Data connection... seems
pretty odd.
I appreciate your help
Thanks
Paul Tag: http://cbt.googletoad.com | Free training Videos Tag: 145620
How do I insert sysdate into a column
I am using OLEDataAdaptor, DataTable and DataRow to insert a row like
dr["CREATEDDATE"] = ......
My question is how do I set that column to "Oracle sysdate"
TIA. Tag: http://cbt.googletoad.com | Free training Videos Tag: 145615
10 million visitors per month
10 000 000 uniques. ! unique = 1 page view. Site is ASP.NET 2.0 and SQL
Server 2005. 1 visit is 3-5 database access (smal number of fields with
datareader). No pictures or other multimedia, only text.
Can I run this on some good shared hosting like www.re-invent.com or
www.hostinguk.net or I need to VPS for this site? Tag: http://cbt.googletoad.com | Free training Videos Tag: 145609
CSV File with OleDB
Hello,
I am currently experiancing a problem with and OleDB connection to a CSV
file using C#. The file is in a folder with permissions set full to eveyone
and when users other that the administrator try to execute the following
code it returns "unspecified error" at the line containing "da.Fill(dt);".
When an admin user tries there is not a problem.
-------------------------------------------------------------
FileInfo fi = new FileInfo(@"E:\CSVFile\output.csv");
DataTable dt = new DataTable();
string optOutConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
fi.DirectoryName + ";Extended Properties='text;HDR=Yes;FMT=Delimited'";
using (OleDbConnection _OptOut = new OleDbConnection(optOutConStr))
{
string sqlTxt = "SELECT * FROM [" + fi.Name + "] WHERE [CompCounter] is
NOT NULL";
OleDbCommand cm = new OleDbCommand(sqlTxt, _OptOut);
OleDbDataAdapter da = new OleDbDataAdapter(cm);
da.Fill(dt);
}
-------------------------------------------------------------
Thanks,
-Scott Tag: http://cbt.googletoad.com | Free training Videos Tag: 145606
Strongly typed Datasets and TableAdapter separation.
Hi,
I would like to have all my strongly typed datasets in a classlibrary.dll
and share the DLL across all solution tiers. The serious problem with this
approach is that I cannot separate TableAdapters from DataSets.
Is there any possible way to separate TableAdapter s from strongly typed
datasets?
Any help would be appreciated,
Max Tag: http://cbt.googletoad.com | Free training Videos Tag: 145603
How to determin if a datarow has already been added to a datatable yet.
using .net 3.0 and c#, I have a public datarow from a strongly typed dataset
datatable. the datarow gets created using the method
myTable.NewmyTableRow(), but doesn't get added to the table until later. At
some point later, is there a quick and easy way determine if the datarow has
already been added to the datatable yet?
--
moondaddy@newsgroup.nospam Tag: http://cbt.googletoad.com | Free training Videos Tag: 145599
Dataset designer uses username as schema
I've created a typed dataset. I've dragged some tables onto the
dataset. When configuring the corresponding table adapter, Visual
Studio is generating SQL script code such as...
CREATE PROCEDURE DOMAIN\UserId.StoredProcName
AS...
The userid is being used as the schema, it is invalid syntax. My
userid is set to use dbo as the default schema, why is dbo not being
used in the script?
Using SQL 2005, Visual Studio 2005. Any ideas? Thanks
Adam Tag: http://cbt.googletoad.com | Free training Videos Tag: 145592
Problems with strongly typed dataset not working
The program below clearly populates the data set as seen by dumping the XML.
I'm using strongly typed data sets.
(1) Why does not my loop to dump row by row work? The record count is zero!
This is clearly wrong from the XML that is dumped!
(2) Why does not my attempt to add a new row work? I don't see "sari" in the
xml or the database when I am done!
Thanks
Siegfried
Dim sqlConnection As New System.Data.Odbc.OdbcConnection(cs)
Dim sqlCommand As New System.Data.Odbc.OdbcCommand(sel, sqlConnection)
'Dim ds As New DataSet()
Dim ds As New OdbcSimple_mdb4
Dim da As New System.Data.Odbc.OdbcDataAdapter(sel, sqlConnection)
da.Fill(ds)
Dim dt As DataTable = ds.Tables(0)
' Use the constructor that takes a type and XmlRootAttribute.
Dim ser1 As New
Xml.Serialization.XmlSerializer(GetType([OdbcSimple_mdb4]))
Dim tw1 As TextWriter = System.Console.Out
ser1.Serialize(tw1, ds)
#If noprompt Then
outp.WriteLine("exiting DisconnectedRS.vb")
#Else
outp.Write("Enter any key to continue DisconnectedRS.vb: ")
_getch()
#End If
Dim t As OdbcSimple_mdb4.simpleDataTable
t = ds.simple
outp.WriteLine("row count = " & t.Rows.Count)
Dim r As OdbcSimple_mdb4.simpleRow
For Each r In t
outp.WriteLine(r.sDescription & "," & r.dtCreation)
Next
r = t.NewRow
r.dtCreation = New DateTime(2008, 6, 18)
r.sDescription = "Sari"
ds.simple.AcceptChanges()
Dim ser2 As New
Xml.Serialization.XmlSerializer(GetType([OdbcSimple_mdb4]))
Dim tw2 As TextWriter = System.Console.Out
ser2.Serialize(tw2, ds) Tag: http://cbt.googletoad.com | Free training Videos Tag: 145584
Problem with LINQ update
Hi All
I have a view in my DB which returns records with no unique identifier. So i
am not able to set the primary key. For example i have three tables
(customer, order, address) which are joined in the view and my result set has
customer data replicated. To display in the screen am doing Distinct and
where customer Id = 1 and getting the company details. but when i have to
update since there is no primary key my update fails.....any idea how to work
around this....... Tag: http://cbt.googletoad.com | Free training Videos Tag: 145583
Problem wiht ado net 2.0
I'have a problem. Ado net 2.0 is resulting very slowly. I'vemade a
test in which i write 100000 record in a database with VB6 Dao and
with VB2005 ADO net 2.0. In the first case the time elapsed for the
operation is 2 second, in the second case the time elapsed is 2
minutes. Can anyone help me to find where i wrong (if i wrong
something...).
in particulary the most part of the time is used for complete the
Update method.
The vb2005 code tha i've use for the test is this:
----------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.Label1.Text = Now
Dim ds As New dbprovaDataSet
Dim tab As dbprovaDataSet.tabella1DataTable = ds.tabella1
Dim riga As dbprovaDataSet.tabella1Row
Dim i As Integer = 0
For i = 1 To 100000
riga = tab.Newtabella1Row
riga.campo = i
tab.Addtabella1Row(riga)
Next
Me.Label2.Text = Now
adap.Update(tab)
Me.Label3.Text = Now
MsgBox("fine")
End Sub
---------------------------
thank U for Help and excuse me for my bad english. Tag: http://cbt.googletoad.com | Free training Videos Tag: 145581
dataset
What is the best way to handle disposing of a DataSet or DataReader within a
function that returns either? Or should i just trust that its gone when it
goes out of scope? Tag: http://cbt.googletoad.com | Free training Videos Tag: 145578
how to insert NCLOB value with System.Data.OracleClient
Hi,
I am trying to use an OracleParameter object to insert a value into an NCLOB
column - the value is stored as a string variable in c# and contains
non-ansi characters.
from what I can understand, I need to set the OracleType property which also
sets the DbType property in the superclass
if I set the OracleType to be nvarchar, some values seem to insert Ok but
some others give this error:
ORA-01461: can bind a LONG value only for insert into a LONG column
it doesn't seem completely dependent on the length of the data but I presume
this is the underlying problem.
so I have tried setting OracleType = OracleType.NClob. however, this gives
ORA-01084: invalid argument in OCI call
any idea how what I am doing wrong? FWIW i'm connected to 10g rel 10.2.0.1.0
and my code looks like this:
IDbConnection conn = new OracleConnection();
conn.ConnectionString = "...";
conn.Open();
IDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO xxx (xxx) VALUES (xxx, :1, xxx )";
IDbDataParameter param = cmd.CreateParameter();
param.ParameterName = ":1";
param.Value = "xxx";
((OracleParameter)param).OracleType = OracleType.NClob;
param.Direction = ParameterDirection.Input;
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();
Thanks
Andy Tag: http://cbt.googletoad.com | Free training Videos Tag: 145574
Create Diffgram Based on 2 Different XML Files or Data Sets
I have an xml file that my application downloads on a periodic basis. I also
have a dataset based on this that is used in the application. At present,
the application takes the new downloaded xml, creates a data set from that
and merges it with one in use. The ultimate goal is to have the update of
the primary data set trigger change events based on only data that has
changed (updates, additions, or deletions).
I am thinking that I need to generate a diffgram based on the current data
and the newly downloaded data and then apply that to the current dataset. Is
this the propper approach, and what is the best way to do this. I am seeing
some postings regarding an XMLDiffPath tool, but they are several yeares
old. How is this done now?
TIA
--
Howard Swope [ mailto:howard.swopeATnavteqDOTcom ]
Technical Lead
Media Development
Navteq Traffic [ http://www.navteq.com ] [ http://www.traffic.com ] Tag: http://cbt.googletoad.com | Free training Videos Tag: 145572
LINQ to SQL, over ASP.NET, DataContext.GetTable trouble
Hi,
Working with LINQ to SQL over an ASP.NET application (VS2008, .NET 3.5)
while calling
"MyDataContextInstance.GetTable<MyTable>()"
it produces sometimes the following exception:
"an item with the same key has already been added"
I think is some trouble about concurrency or async calls
(MyDataContextInstance is an static variable).
Could it be a problem related to ASP.NET application lifecycle management?
or...
a LINQ to SQL (DataContext) bug not supporting concurrency?
Thanks in advance for your time.
Néstor Sánchez A. Tag: http://cbt.googletoad.com | Free training Videos Tag: 145565
Dataset and XML
Hi Gurus,
I have a very simple question. Please answer.
Is it true that when we load Data into a Datasets from SQLServer it loads it
in XML format?
I am curious to know how it loads data.
I appreciate any knowledge I gain.
Thanks
Mark Tag: http://cbt.googletoad.com | Free training Videos Tag: 145563
ExecuteDynamicInsert Bug
I'm trying to simulate an "ON INSERT" AND "AFTER INSERT" trigger in LINQ
the code I use is this:
partial void InsertEvent(Event instance)
{
Group group = new Group();
group.GroupId = Guid.NewGuid();
group.DateCreated = DateTime.Now;
group.OwnerId = instance.OrganizerId;
group.Name = instance.Title + " Event Group";
group.Description = instance.Description;
group.Permission = 3;
base.ExecuteDynamicInsert(instance);
///this will fail because the database is unable to check the
constrain
///on groupEvent.EventId
///
///
NewDataContext context1 = new NewDataContext();
GroupEvent groupEvent = new GroupEvent();
groupEvent.GroupEventId = Guid.NewGuid();
groupEvent.GroupId = group.GroupId;
groupEvent.EventId = instance.EventId;
context1.GroupEvents.InsertOnSubmit(groupEvent);
context1.SubmitChanges();
}
base.ExecuteDynamicInsert(instance); lock the table in which instance is
inserted
so the constraint groupEvent.EventId = instance.EventId; on sql cannot be
verified and the insert of GroupEvent fail....
any idea on how to do it? Tag: http://cbt.googletoad.com | Free training Videos Tag: 145562
Visual Studio 2008 SP1(beta) - ADO Entity Data Model template is not available.
Hi All
I want to try out this tutorial
http://blogs.microsoft.co.il/blogs/bursteg/archive/2008/05/12/visual-studio-2008-sp1-ado-net-data-service-walkthrough.aspx
with the new ADO Data Service (code name Astoria). When I hit step 2, I
can't find any item template ADO.NET Entity Data Model. Has anyone seen this
problem with their installation of VS SP1 beta.
Cheers,
tc Tag: http://cbt.googletoad.com | Free training Videos Tag: 145547
How to move table definitions?
What is the easiest way to move table definitions between various databases?
For example: if I have a excel spreadsheet with column headers, how can I
move the table definition (excel seems to be able to detected data types like
dates and integers and strings) to MSAccess or SQL server or MySQL?
I was going to interrogate the data set for the column types and use ADOX to
create the table definitions. The data set won't give me primary key and
foreign key information though. Is there an easier way?
Thanks,
Siegfried Tag: http://cbt.googletoad.com | Free training Videos Tag: 145546
Best way to reinvent bulk insert?
Which is more efficient: a long series of SQL INSERT statements or
deserializing a dataset from XML and saving it to the table?
If I fill a dataset with current sample data and serialize it to XML, can I
expect to use that as a template to subsequently populate the table in the
future?
This way I can keep the XML under version control as well.
What function to I call to save a deserialized data set to a table?
We have been using bulk insert with sqlcmd but that is difficult to debug
and is specific to SQL Server. Tag: http://cbt.googletoad.com | Free training Videos Tag: 145540
LINQ vs. Traditional ADO .NET
As I start learning LINQ (and say to myself it's about time they came up
with a simple way to do querying of various data models) I am forced to
wonder, with the new classes in LINQ to SQL in particular, if there is any
performance impact of using things like DataContexts and tables, rather than
the traditional Connection, Command, DataSet classes.
I know that these LINQ classes map to the ADO .NET classes, but is there any
additional overhead to using them?
Also, since Strongly-Typed datasets used to be the way to go as a best
practice, does LINQ (and its table classes) make them obsolete for certain
purposes?
Thanks,
Scott Tag: http://cbt.googletoad.com | Free training Videos Tag: 145538
Run multiple queries simultaneously with SQL Compact 3.5???
is it possible to have several queries in 1 query command (as far as i read
on the Microsoft pages this should be possible but i don't succeed):
in fact something like:
...
string sql = string.Format(select * from A; select * from B;);
... Tag: http://cbt.googletoad.com | Free training Videos Tag: 145534
How to move data from xls files to MSAccess to SQLServer tables
I have a VB.NET program that will load a DataSet from Excel file and
serialize it to XML.
Is there a simple way to create a table defintion (using ADOX?) from the
data set and then populate the table?
Thanks,
Siegfried Tag: http://cbt.googletoad.com | Free training Videos Tag: 145528
How to translate ado into ado.net?
I want to translate the following script into VB.NET. Does ADO.NET have that
feature of ADO where it can read Excel? What would the connection string?
What classes would I use: the System.data.oleDB or system.data.ODBC?
Thanks,
Siegfried
'
'
' Begin commands to execute this file using windows scripting host with bash
' cscript query.vbs 080604FastPropAdams.xlsx
' End commands to execute this file using windows scripting host with bash
On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001
for kk = 0 to WScript.Arguments.Count-1
Wscript.Echo "begin " & kk & " = " & Wscript.Arguments.Item(kk)
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
WScript.Arguments.item(kk) & ";Extended Properties=""Excel 8.0;HDR=Yes;"";"
objRecordset.Open "Select * FROM [Sheet1$]", objConnection, adOpenStatic,
adLockOptimistic, adCmdText
call DumpFieldNames(objRecordset)
call DumpRecordSet(objRecordset)
next
Wscript.Echo "end query "
Wscript.Quit
Sub DumpFieldNames(objRecordset)
dim sFieldNames
sFieldNames = ""
sFieldTypes = ""
For ii = 0 to objRecordset.Fields.Count -1
If sFieldNames = "" Then
Else
sFieldNames = sFieldNames & ", "
sFieldTypes = sFieldTypes & ", "
End If
sFieldNames = sFieldNames & objRecordset.Fields.Item(ii).Name & "(" &
objRecordset.Fields.Item(ii).Type & "/" &
objRecordset.Fields.Item(ii).DefinedSize & "/" &
objRecordset.Fields.Item(ii).ActualSize & ")"
sFieldTypes = sFieldTypes & objRecordset.Fields.Item(ii).Type
Next
WScript.Echo sFieldNames
WScript.Echo sFieldTypes
End Sub
Sub DumpRecordSet(objRecordSet)
jj = 1
Do Until objRecordset.EOF
' Wscript.Echo objRecordset.Fields.Item("Name"),
objRecordset.Fields.Item("Number")
dim sFieldValues
sFieldValues = ""
For ii = 0 to objRecordset.Fields.Count -1
If sFieldValues = "" Then
Else
sFieldValues = sFieldValues & ", "
End If
sFieldValues = sFieldValues & objRecordset.Fields.Item(ii)
Next
WScript.Echo " <div><a href='#'
onclick='AddPushpin("""&sFieldValues&""");'>Add pushpin
"&sFieldValues&"</a></div>"
WScript.Echo " <div><a href='#'
onclick='Find("""&sFieldValues&""");'>go to "&sFieldValues&"</a></div>"
objRecordset.MoveNext
jj = jj + 1
if jj > 8 then
exit do
end if
Loop
End Sub Tag: http://cbt.googletoad.com | Free training Videos Tag: 145526
sp_setapprole problem (using LINQ)
We have an application that need to call set application role to give
rights to the database objects.
I call 'sp_setapprole' but it's running into error when I try to
GetUser to checks if the change was successfully.
Code:
ExecuteCommand("sp_setapprole 'rolename', 'password'");
'Select User_Name()'
It returns the message: "SQL Error - A severe error ocurred on the
current command. The results, if any, should be discarded" (twice)
In Event Log:
Event Type: Error
Event Source: MSSQLSERVER
Event Category: (2)
Event ID: 18059
...
...
Description:
The connection has been dropped because the principal that opened it
subsequently assumed a new security context, and then tried to reset
the connection under its impersonated security context. This scenario
is not supported. See "Impersonation Overview" in Books Online.
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
When I use connection string with Polling=false, it runs without
error. But the set application role is ignored.
Do you know what is the problem with executing the approle ?
How can I work with setting application roles ?
Thanks in advance Tag: http://cbt.googletoad.com | Free training Videos Tag: 145521
Parameterized query & datetime2
I am using a query for a SqlDataAdaptor to populate the DataSet a table. I
use SqlCommandBuilder to create Insert/Update/Delete query. Can parameterized
query be used in such a case such as WHERE MyColumn = @MyParameter?
For a datatime2 column, what is the format for query?
string.Format("WHERE MyDatetimeColumn = '{0}'",
myDatetime.ToString("yyyy-MM-ddTHH:mm:ss.fff")) only gives to the
millisecond. How to be as accurate as ticks? Tag: http://cbt.googletoad.com | Free training Videos Tag: 145520
BeginEdit/EndEdit doesn't update row
I have the following code:
Dim strContentInfo As String = "ContentID='" & CUID & "'"
Dim drContentInfo As DataRow() =
GlobalDataSet.Tables("PaidContent").Select(strContentInfo)
<Some other stuff happens here to set NumPlays>
drContentInfo(0).BeginEdit()
drContentInfo(0).ItemArray(2) = NumPlays
drContentInfo(0).EndEdit()
drContentInfo(0).AcceptChanges()
GlobalDataSet.AcceptChanges()
However the values in the dataset or even the datarow are not changing. No
errors. I stepped through it to see what was happening and I coud not find
any problems. The HasErrors on the row is false, the RowError = "", but the
RowState says "Unchanged". What is wrong here?
TIA,
--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv Tag: http://cbt.googletoad.com | Free training Videos Tag: 145519
Inserting Multi Table Dataset into Dataset
Hi,
I have a dataset with 6 relational datatables within it. I want to
insert the data into corresponding tables within a SQL db. Is there a
quick way of doing it instead of having to loop through each table
inserting the record and the child datatables? Using C# .NET 2 and SQL
Server 2005.
Thanks! Tag: http://cbt.googletoad.com | Free training Videos Tag: 145518
GridView LINQ double foreign key
I can run the following query in LinqPad
from u in UsersInRoles
select new {u.ApplicationID, u.ApplicationRoles.Application.ApplicationName}
However,
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="ApplicationManagment.ApplicationsDataContext"
TableName="UsersInRoles" StoreOriginalValuesInViewState="False">
</asp:LinqDataSource>
<asp:Label ID="lblApplicationName" runat="server" Text='<%#
Bind("ApplicationRoles.Application.ApplicationName") %>'></asp:Label>
Parser Error Message: A call to Bind was not well formatted. Please refer
to documentation for the correct parameters to Bind.
Is the double link not allowed or wrong syntax in a GridView?
The Primary Key on ApplicationRoles is on ApplicationID, RoleID (FK to
UsersInRoles)
The tables are Applications (description of application; PK ApplicationID)
ApplicationRoles (the roles allowed in an application )
UsersInRoles (users in a role for an application) Tag: http://cbt.googletoad.com | Free training Videos Tag: 145513
Need help with LINQ Query
If I perform a simple select query in my project I'm able to fill my
gridview with no problem. However, once I wonder over to an aggregated
query were I sum two columns I run into tons of problems.
I also could never get this to work with a dataset. Since I only had one
table I opted to use only a datatable. Is that problematic?
Can someone help me out please?
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim dt As New Data.DataTable
Dim dr As Data.DataRow
Dim LineIn As String
Dim XQ
Dim LIN
Dim ZA
Dim StreamReader As System.IO.StreamReader
dt.Columns.Add(New Data.DataColumn("Date", GetType(Date)))
dt.Columns.Add(New Data.DataColumn("UPC", GetType(Int64)))
dt.Columns.Add(New Data.DataColumn("QTY_Sold", GetType(Integer)))
dt.Columns.Add(New Data.DataColumn("QTY_OnHand", GetType(Integer)))
dt.Columns.Add(New Data.DataColumn("Unit_Type", GetType(String)))
StreamReader = IO.File.OpenText("txt.txt")
While StreamReader.Peek <> -1
LineIn = StreamReader.ReadLine()
If Mid(LineIn, 1, 2) = "XQ" Then
XQ = Split(LineIn, "*")
ElseIf Mid(LineIn, 1, 3) = "LIN" Then
LIN = Split(LineIn, "*")
Else
ZA = Split(LineIn, "*")
dr = dt.NewRow()
dr("Date") = Mid(XQ(2), 5, 2) & "/" & Mid(XQ(2), 7, 2) & "/"
& Mid(XQ(2), 1, 4)
dr("UPC") = LIN(3)
dr("QTY_Sold") = "0"
dr("QTY_OnHand") = ZA(2)
dr("Unit_Type") = ZA(3)
dt.Rows.Add(dr)
End If
End While
StreamReader.Close()
'SELECT DATE, UPC, SUM(QTY_Sold), SUM(QTY_OnHand), Unit_Type FROM dt
Dim results As IEnumerable(Of DataRow) = Aggregate o In dt _
Group By UPC_Group =
o.Field(Of Int64)("UPC") _
Into test = Sum(o.Field(Of
Integer)("QTY_Sold")), test2 = Sum(o.Field(Of Integer)("QTY_OnHand"))
DataGridView1.DataSource = results.CopyToDataTable()
End Sub
End Class Tag: http://cbt.googletoad.com | Free training Videos Tag: 145510
Checking db connection for initialising
Hi
I am passing an sqlconnection optional parameter as below;
Optional ByVal DBConn As SqlClient.SqlConnection = Nothing
I have given it an initial value of nothing howee rwhe I try to test for
nothing like;
If DBConn = Nothing
I get an 'Operator '=' is not defined for types
'System.Data.SqlClient.SqlConnection' and
'System.Data.SqlClient.SqlConnection' error. What am I missing and how can I
check if a value was in fact passed for the optional parameter DBConn?
Thanks
Regards Tag: http://cbt.googletoad.com | Free training Videos Tag: 145502
Accessing sql server from behind isa 2000
Hi
My app am unable to access a remote sql server (hosted by our web host) from
a sbs 2003 premium (with isa 2000). The app bombs with the error; An error
has occurred while establishing a connection to the server. When connecting
to SQL Server 2005, this failure may be caused by the fact that under the
default settings SQL Server does not allow remote connections. (provider:
Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I have tried osql command and I get below results;
C:\Documents and Settings\Administrator>osql -E -Stcp:mysqlserver.com
[DBNETLIB]SQL Server does not exist or access denied.
[DBNETLIB]ConnectionOpen (Connect()).
Do I need to open any ports on ISA Server 2000? The sql server is accessible
fine from a standalone pc that is not connected to sbs.
Thanks
Regards Tag: http://cbt.googletoad.com | Free training Videos Tag: 145501
.net 3.5 setup bombs
Hi
When I try to install .net 3.5 framework on a windows 2003 sp1 server it
bomb with the following info;
AppName: setup.exe AppVer: 9.0.21022.8 AppStamp:47316ce5
ModName: sitsetup.dll ModVer: 9.0.21022.8 ModStamp:47316ce2
fDebug: 0 Offset: 000c3223
What is the problem and how can I fix it?
Thanks
Regards Tag: http://cbt.googletoad.com | Free training Videos Tag: 145498
insert data in an access db with C# (update)
I've got the problem that after doing an INSERT, I can't see the new records
in my database.
What can I force an UPDATE, before close the databse?
Thanks.
Now, I'm doing...
String evento = "1";
String suceso = "actualizacion";
String fecha = System.DateTime.Now.ToString();
String usuario = "user";
OleDbConnection myConn = new
OleDbConnection(TabStripApp.Properties.Settings.Default.onlydentConnectionString);
String cadena="insert into Log (Tipo_evento,Suceso,Fecha,Usuario) values
('"+evento+"','"+suceso+"','"+fecha+"','"+usuario+"')";
OleDbCommand myComm = new OleDbCommand(cadena, myConn);
myConn.Open();
myComm.ExecuteNonQuery();
myConn.Close(); Tag: http://cbt.googletoad.com | Free training Videos Tag: 145495
SQL XML query and serialized DataSet
Crosspost : microsoft.public.dotnet.framework.adonet,
microsoft.public.dotnet.general, microsoft.public.sqlserver.programming
FU2 : microsoft.public.dotnet.general
Hello,
Do you know a clever method to convert an xml query result (FOR XML RAW,
ELEMENTS, XMLSCHEMA, ROOT') into an serialized System.Data.DataSet ?
Thanks.
--
Fred
foleide@free.fr Tag: http://cbt.googletoad.com | Free training Videos Tag: 145483
Error running sql command
Hi
I have below code;
Cmd = New SqlCommand("SELECT * FROM MyTable01", DBConnectionRemote())
Reader = Cmd.ExecuteReader()
While (Reader.Read())
ID = CInt(Reader.GetValue(Reader.GetOrdinal("ID")))
Dim delstr As String = "DELETE FROM MyTable02 WHERE [MyTable2].ID = " &
ID.ToString
Dim delCmd As New SqlCommand(delstr, DBConnectionRemote())
delCmd.ExecuteNonQuery()
End While
I am getting a 'System.InvalidOperationException: There is already an open
DataReader associated with this Command which must be closed first' error on
the delCmd.ExecuteNonQuery() statement. What is the problem and how can I
fix it?
Thanks
Regards Tag: http://cbt.googletoad.com | Free training Videos Tag: 145481
login/password C# and access.
Hello again!
I've got a typical problem validating a user/pass through an access database
with C#. I tried with two functions, and both tell me that the resulting
string is out of context.
How could I solve it?
Thanks.
Boolean comprueba_loguin(String usuario,String password)
{
String prueba,cadena;
OleDbConnection myConn = new
OleDbConnection(TabStripApp.Properties.Settings.Default.onlydentConnectionString);
OleDbCommand myComm = new OleDbCommand("select usuario,password from
usuarios", myConn);
myConn.Open();
OleDbDataReader myReader = myComm.ExecuteReader();
if (myReader.HasRows)
{
cadena = myReader.GetString(0);
myReader.Close();
return true;
}
else
{
myReader.Close();
return false;
}
}
Boolean comprueba_loguin2(String usuario, String password)
{
String prueba, cadena;
String sqlquery= "select usuario,password from usuarios";
String ConnectionString =
TabStripApp.Properties.Settings.Default.onlydentConnectionString;
OleDbConnection con = new OleDbConnection(ConnectionString);
OleDbCommand cmd = new OleDbCommand(sqlquery, con);
con.Open();
cmd.ExecuteNonQuery();
object resultquery = cmd.ExecuteReader();
string resultado = resultquery.ToString();
con.Close();
return true;
} Tag: http://cbt.googletoad.com | Free training Videos Tag: 145476
Accent Insensitive DataTable.Select
I have a DataTable with data in it. I use the Select method to "find"
certain rows. The problem with this method is that it performs an
Accent Sensitive filter on the data. I need Accent Insensitive:
Andr=E9=3DAndr=E8=3DAndre.
I tried setting the DataTable Locale to CultureInvariant but it
doesn't solve my problem. I can't find any information on how to
create an Accent Insensitive CultureInfo. I also see the DataTable has
a private CompareInfo field but I can't access it.
If anyone can provide any kind of pointers to possible solutions, I
would appreciate it.
Thanks.
Joel Tag: http://cbt.googletoad.com | Free training Videos Tag: 145469
how to get information of unique constriantant form ODBC
With ADO I can get such information from access or sqlserver,but it doesn't
work on ODBC,what is right way for ODBC?
--
jtz Tag: http://cbt.googletoad.com | Free training Videos Tag: 145468
Oracle Cursors with .Net
Hi,
I am having an argument with our DBA, he is under the impression that
it is the .net api always opens a cursor.
However I believe that Oracle always opens a cursor for any select
statement.
Can someone shed some light?
Regardless of what the answer is, why is it that oracle relies so
heavily on cursors?
-Edward Tag: http://cbt.googletoad.com | Free training Videos Tag: 145466
LINQ-to-SQL Previous values?
I have implemented a solution where I use LINQ-to-SQL to map all my objects
to SQL database. Now I want to create an automated history log of the main
objects. Objects are changed on several places in the application so my
intention was to call an AddHistory method everytime the Insert and Update
methods of the DBML file are called. The basic idea works fine, but I run
into some tricky problems on the details.
What is the best way to obtain previous values of the object?
I would like to log a descriptive text to make the user understand what has
happened.
My first try was to call the database just before the saving, to read
current database values just before they are changed. I created a temporary
datacontext object and used it to return the single object. Then I compared
all relevant properties between the current object and the database version
and logged every difference.
It worked fine for all simple properties but for extended properties
compiled from related tables I have some problems. With extended properties I
mean lookup values related to other tables. I don't want to refer to integer
values but rather the friendly names the user is used to!
If the temporary datacontext is closed before values are read I can not read
values from other tables. But if I keep the temporary datacontext alive it
will block cascading updates on related objects in same table.
Is it possible to create ReadOnly datacontext that will not block updates?
A completely different approach would be to create a detached oldvalue
collection inside the object from the beginning. Before saving the object it
would be easy to compare saving values with previous.
But extended properties need to be taken into account here as well! If I
retrieve a big collection of objects I don't want to slow down the initial
work by retrieving a lot of lookup values from other tables. In most cases
they will probably not be used anyhow.
Can I somehow INSIDE my partial class code detect when the PropertyChanging
event is fired? When a property is going to change seems to be a good place
to retrieve the previous values.
Any help is appreciated. Tag: http://cbt.googletoad.com | Free training Videos Tag: 145465
http://cbt.googletoad.com
Microsoft, Cisco , Vmware , Oracle , Java and all kind of training
videos are here for free.