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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg 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: iiojioji ojio jiofer gergergergerger gergerg Tag: 145465
Deserialize DataSet cuase err:Permission denied
I try ADO 2 with binary like that:
======================
on server i send ms to client
======================
ds.RemotingFormat = SerializationFormat.Binary
Dim myFormatter As Runtime.Serialization.IFormatter = New _
Runtime.Serialization.Formatters.Binary.BinaryFormatter
ms = New MemoryStream
myFormatter.Serialize(ms, ds)
================
on client I got the ms
================
ms.Position = 0
ds.RemotingFormat = SerializationFormat.Binary
Dim myFormatter As Runtime.Serialization.IFormatter = New _
Runtime.Serialization.Formatters.Binary.BinaryFormatter
ds = myFormatter.Deserialize(ms)
the last line cause err:
"Permission denied: cannot call non-public or static methods
remotely." Tag: iiojioji ojio jiofer gergergergerger gergerg Tag: 145460
Problem running delete query on remote server
Hi
My app's connection is with an access database but I am running the below
query to delete records on a remote sql server;
DELETE [My Table].*
FROM [ODBC;Driver=SQL
Server;SERVER=mysqlserver.net;DATABASE=mydatabase;UID=myusername;PWD=mypassword].[My
Table]
WHERE [My Table].ID = 3
I am getting a 'Could not delete from the specified tables' error and
explanation is 'In order to evaluate an indexed property, the property must
be qualified and the arguments must be explicitly supplied by the user.'.
The Insert and Select queries on the remote server work fine from within
Access. Also as I can delete the records manually form the remote server I
presume there are no permissions issues. What is the problem and how can I
fix it? Detailed stack trace is given at the end below.
Thanks
Regards
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147467259
Message="Could not delete from specified tables."
Source="Microsoft JET Database Engine"
StackTrace:
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) at
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at
IV.clsStaffProcessSiteDB.ProcessStaffSiteDB() in C:\HS Comm Server 2008\HS
Comm Server\clsStaffProcessSiteDB.vb:line 216 at
IV.modMain.ProcessStaff() in C:\HS Comm Server 2008\HS Comm
Server\modMain.vb:line 23 at IV.modMain.Process() in C:\HS Comm Server
2008\HS Comm Server\modMain.vb:line 115 at
IV.frmHSCommServer.Events_Timer_Tick(Object sender, EventArgs e) in C:\HS
Comm Server 2008\HS Comm Server\frmHSCommServer.vb:line 52 at
System.Windows.Forms.Timer.OnTick(EventArgs e) at
System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) at
System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam) at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context) at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context) at
System.Windows.Forms.Application.Run(ApplicationContext context) at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine) at IV.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args) at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at
System.Threading.ThreadHelper.ThreadStart_Context(Object state) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()
InnerException: Tag: iiojioji ojio jiofer gergergergerger gergerg Tag: 145448
learning C# ; first problem with access, and datasets
Hi!!
I'm doing a form to make a login, so, user and pass.... and so on.
The problem is that first of all, I check how many records are in the table,
and later I would like to make a do/while. With count it shows always '0'
records, and there's 1 record.
I've got a dataset called usuarios, and with:
int numero;
numero = usuarios.Tables.Count;
Form1 formulario1=new Form1();
formulario1.Show();
IT shows a message like this: The name 'numero' does not exist in the
curent context.
And I don't understand...
Furthermore, in the Form1, I'm doing the same with other table, and it works
fine. Tag: iiojioji ojio jiofer gergergergerger gergerg Tag: 145446
Interaction command and functions (tutorial)
Reason of this project:
The Microsoft.VisualBasic.Interaction class exposes many useful
commands and methods that were available in Visual Basic like
AppActivate, Beep, Callbyname...
This tutorial shows how to work with some of them.
Project details:
1- From VB 6.0 to VB .net 2.0
2- Useful interaction commands
3- Samples of interaction commands
1- From VB 6.0 to VB .net 2.0
There was several changes on VB .net (it's a big change and that's
clear). Although in an effort to make the transition from VB 6 to VB
2005 as easy as possible, Microsoft has gathered most of the Visual
Basic 6.0 commands and functions in the Microsoft.VisualBasic.dll
assembly.
Some of the commands and functions was deleted, other still the same
and others changed to the .net syntax.
For Example:
VbCrlf which is used on VB 6.0 (as a separator) still alive on VB .net
2.0 but a new syntax is already available for use.
ControlChars.crlf is the new method
As you are using VB .net I recommend that use the new syntax, and I'm
going to introduce some of the important change between the old and
the new syntax.
2- Useful interaction commands
VB 6.0 syntax contain many useful interaction commands and function
like the Message Box for example. Those commands still alive but have
been improved in the .net 2.0 version.
Shell Function:
The shell function runs an executable program, it works like the
command line so you can use it as a command line.
The shell function is capable of returning an integer indicating if
the program still running or not. The shell function was expanded in
the .net 2.0 version and supports an additional argument that enables
you to specify whether to wait until the shelled program terminates
with an optional timeout.
Use of the function
Shell (Application Path, Style, Wait, Timeout)
Example:
' Run Notepad.exe and wait until the user terminates it.
Shell ("notepad", AppWinStyle.NormalFocus, True)
AppActivate Function:
AppActivate is a cool function that may be helpful if you are
developing application for Windows. Now let see how this works and
what it do. The AppActivate function as it names, activate a currently
running application.
How it activates? Simply by giving the focus to the application
Window.
The function is quite useful and require only to know the windows
caption!
Use of the function
AppActivate ( Title) or AppActivate (ProcessID)
NB: You have to choose either to use the title or the processID and
not both!
Now let's see this example
' Activate the NotePad Window
AppActivate("Untitled - Notepad")
Now as we know those simple functions we can use them to build helpful
projects and application. Now see the sample of the interaction
commands.
3- Samples of interaction commands
This sample is exactly a direct (little expanded) application of the
two functions that we have studied together right now.
There's only one sample and if you run it you'll get a window with 2
buttons.
Each button introduce a sample for each function. The button caption
let you distinguish them.
The Shell sample:
Run a notepad application and return a message if the NotePad was
closed.
If the timeout was exceeded (5 seconds), return a message that the
NotePad still running
The AppActivate:
The following sample run a notepad with no focus and use AppActivate
to give it the focus.
So the sample use both of the functions
Download the source code
http://thedotnetsource.blogspot.com/2008/05/tutorial-7-interaction-commands-and.html
The Zip file contains:
-The sample source code
-The readme.txt file
-The tutorial.txt file
Still have question:
Go to our blog (http://thedotnetsource.blogspot.com). Select the
tutorial post. Post a comment describing your problem.
If you have a general question, we highly recommend the MSDN Forums as
the best Dot Net forums in the net. Tag: iiojioji ojio jiofer gergergergerger gergerg Tag: 145445
Update Concurrency Error
I have a seemingly straightforward Update Query that works fine in query
analyzer.
However, when I put it into code either by using an TableAdapter Object data
source, or Manually, I get a concurrency error and I can't figure out why...
here's the basic sql for the update (followed by my manual attempt to
program it)
UPDATE PPU.tbl_Users_Main
SET ProvNUID = @ProvNUID,
ProvID = @ProvID,
ProvHC_ID =@ProvHC_ID,
ProvName = @ProvName,
[Alias] = @Alias, Role = @Role,
Type = @Type
WHERE (UserID = @Original_UserID)
Yes, I realize the shortcoming of using the words 'Alias' and 'Type', but
the designer unfortunately, named it this and most of the program has code
that already works with it, so although I hate to keep using the names, I may
have to.
Here is the attempt to program it into an aspx page using a lnk button:
Protected Sub lnkEditUpdateIns_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lnkEditUpdateIns.Click
Select Case Me.lnkEditUpdateIns.Text
Case "Edit"
Me.lnkEditUpdateIns.Text = "Update"
Me.lnkNewCancel.Text = "Cancel"
EnableUserBoxes(True)
SaveRecordForCancel()
Case "Update"
Dim NV As New PCPUser
Dim SR As New PCPUser
NV = GetNewValues()
SR = Session("ssCur")
'update the user and return any error message
Select Case UpdateUser(NV, SR)
Case DBResult.Success
Me.lnkEditUpdateIns.Text = "Edit"
EnableUserBoxes(False)
Case DBResult.ConcurrencyError
Me.lblInform.Text = "Concurrency error"
Case DBResult.DatabaseError
Me.lblInform.Text = "An Error occured in the database"
End Select
Case "Insert"
Me.lnkEditUpdateIns.Text = "Update"
End Select
End Sub
Private Function GetNewValues() As PCPUser
Dim SR As New PCPUser
SR.ProvNUID = Me.txtNUID.Text
SR.ProvID = Me.txtProvID.Text
SR.ProvHC_ID = Me.txtHC_ID.Text
SR.ProvName = Me.txtProvName.Text
SR.ProvAlias = Me.txtAlias.Text
SR.Role = Me.cmbRole.SelectedValue
SR.ProvType = Me.cmbType.SelectedValue
Session("ssNew") = SR
Return SR
End Function
Public Shared Function UpdateUser(ByVal NewUser As PCPUser, ByVal
OldUser As PCPUser) As DBResult
Dim cn As SqlConnection = GetVitalsConnection()
Dim sSqlCommand As String = "UPDATE PPU.tbl_Users_Main " _
& "SET ProvNUID = @ProvNUID, ProvID = @ProvID, ProvHC_ID =
@ProvHC_ID, ProvName = @ProvName, [Alias] = @Alias, Role = @Role, Type =
@Type " _
& "WHERE (UserID = @Original_UserID)"
cn.Open()
Dim cmdUsers As New SqlCommand(sSqlCommand, cn)
With cmdUsers.Parameters
.AddWithValue("@ProvNUID", NewUser.ProvNUID)
.AddWithValue("@ProvID", NewUser.ProvID)
.AddWithValue("@ProvHC_ID", NewUser.ProvHC_ID)
.AddWithValue("@ProvName", NewUser.ProvName)
.AddWithValue("@Alias", NewUser.ProvAlias)
.AddWithValue("@Role", NewUser.Role)
.AddWithValue("@Type", NewUser.ProvType)
.AddWithValue("@Original_UserID", OldUser.UserID)
End With
Try
If cmdUsers.ExecuteNonQuery() > 0 Then
UpdateUser = DBResult.Success
Else
UpdateUser = DBResult.ConcurrencyError
End If
Catch ex As Exception
UpdateUser = DBResult.DatabaseError
End Try
cn.Close()
cn.Dispose()
cn = Nothing
End Function
Private Function SaveRecordForCancel() As PCPUser
Dim SR As New PCPUser
SR.ProvNUID = Me.txtNUID.Text
SR.ProvID = Me.txtProvID.Text
SR.ProvHC_ID = Me.txtHC_ID.Text
SR.ProvName = Me.txtProvName.Text
SR.ProvAlias = Me.txtAlias.Text
SR.Role = Me.cmbRole.SelectedValue
SR.ProvType = Me.cmbType.SelectedValue
Session("ssCUR") = SR
Return SR
End Function
Any suggestions? Tag: iiojioji ojio jiofer gergergergerger gergerg Tag: 145441
Datagrid doesn't see restrictions on datatypes
Hi
I have the following XML Schema
<xs:element name="MotionParameters">
<xs:complexType>
<xs:sequence>
<xs:element name="FeedRateMAX" >
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minExclusive value="0.0"/>
<xs:maxExclusive value="1000.0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="PlungeRateMAX" type="xs:double"
minOccurs="0" />
<xs:element name="TravelRateMAX" type="xs:double"
minOccurs="0" />
<xs:element name="TravelRate" type="xs:double" minOccurs="0" />
<xs:element name="PlungeRate" type="xs:double" minOccurs="0" />
<xs:element name="FeedRate" type="xs:double" minOccurs="0" />
<xs:element name="JogSpeedMode" type="xs:integer"
minOccurs="0" />
<xs:element name="SeekXYSpeed" type="xs:double" minOccurs="0" />
<xs:element name="SeekZSpeed" type="xs:double" minOccurs="0" />
<xs:element name="JerkGrate" type="xs:double" minOccurs="0" />
<xs:element name="AccelerationG" type="xs:double"
minOccurs="0" />
<xs:element name="AccelMAX" type="xs:double" minOccurs="0" />
<xs:element name="JerkMAX" type="xs:double" minOccurs="0" />
<xs:element name="CentripetalG" type="xs:double" minOccurs="0"
/>
<xs:element name="BrakeG" type="xs:double" minOccurs="0" />
<xs:element name="ArcError" type="xs:double" minOccurs="0" />
<xs:element name="MinLength" type="xs:double" minOccurs="0" />
<xs:element name="CornerPause" type="xs:double" minOccurs="0" />
<xs:element name="StartPause" type="xs:double" minOccurs="0" />
<xs:element name="JerkFactor" type="xs:integer" minOccurs="0" />
<xs:element name="CentripetalAcceleration" type="xs:double"
minOccurs="0" />
<xs:element name="LinearAcceleration" type="xs:double"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
I read the schema in using a dataset as in the following:
dsMachineParameters = new DataSet("MachineParameters");
mydatagrid = new DataGrid();
mydatagrid.DataSource = dsMachineParameters;
dataGridView1.Controls.Add(mydatagrid);
try
{
dsMachineParameters.ReadXmlSchema(xmlSchemaPath);
dsMachineParameters.ReadXml(xmlPath);
mydatagrid.Controls.Clear();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
return;
}
I am still able to set values outside the range I set for FeedRateMAX?
How do I make the grid understand the restrictions I have put on this value?
I still able to change this value in the grid outside of the range I have set.
--
Don Tag: iiojioji ojio jiofer gergergergerger gergerg Tag: 145440
SQLParamter setting.
Hi all,
i am having query which is using in operator and there i want to pass
integetvalue.
say like select * from employee where empid in(1,2,3);
here empid i have to pass dynamically so how will i use sqlparameter
for this?
please help me asap.
thanks in advance. Tag: iiojioji ojio jiofer gergergergerger gergerg Tag: 145436