|
Hi every body,
I have two questions which I failed to know their answers:
1- What is the best to make an ADO.NET connection with a DB (in a form in VB.NET) with one table in or with many tables but have a relationship between them through SQL?Why?
2- What is the best technique used in Vb.net to make a form has a connected DB. Is it by writing the code by ourselves Or, by using the available ADO.NET data providers(OLEDB) in the Toolbox in VB.NET?Why?
With Thanks.
-- modified at 8:57 Thursday 20th October, 2005
|
|
|
|
|
Deema Jack wrote: 1- What is the best to make an ADO.NET connection with a DB (in a form in VB.NET) with one table in or with many tables but have a relationship between them through SQL?Why?
There are many different ways. All have their pros and cons depending on the situation and what you want to use it for. What do you want to do?
Deema Jack wrote: 2- What is the best technique used in Vb.net to make a form has a connected DB. Is it by writing the code by ourselves Or, by using the available ADO.NET data providers(OLEDB) in the Toolbox in VB.NET?Why?
The best "technique" is to use some sort of data abstraction model. Create a class (or set of classes) whose responsibility is to access the database and let your form get on with the job of dealing with the user interface. Let everything do its thing well, rather than create some sort of monster that cannot do anything well.
If you think this answer is not very good it is because I am attempting to provoke you into starting a discussion where you tell us more about what you are doing and then perhaps we can guide you towards the right way to do it.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
I think I may be missing something simple as I can't find a similiar problem on the internet, so any help would be greatly appreciated. I am trying to access an SQL Server database through sharepoint via a web part. However I have sql client permission errors.
An Error has occurred: Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
I have tried many different connection strings and authentication modes but always have the same error.
The connection string currently is:"Data Source=lons3003;Initial Catalog=FF;Integrated Security=SSPI;"
Thanks in advance
|
|
|
|
|
Integrated Security? This means you have to give the web service thread the proper rights to access the SQL server. I usually go with a SQL username/password scheme instead of giving IUSR_* anonomous accounts any real domain rights.
|
|
|
|
|
Thank you for responding but I still have the same problem using username and password.
server = Server;database=db;uid=sa;persist security info = true;
any other suggestions?
|
|
|
|
|
Your Connection string should look something like this:
"Server=Aron1; Database=pubs; User ID=bob; Password=asdasd; Trusted_Connection=False"
I hope you are not using 'sa' (with or without a password).
I would create a specfic user on the SQL server with the exact rights necessary to accomplish your goals. It doesn't make sense to expose your system to the Internet like that.
You will find a whole set of connection string patterns on: www.connectionstrings.com [^]
|
|
|
|
|
Cheers. But I get the same problem using the username and password string.
|
|
|
|
|
Is your web server out of your domain/firewall zone? Maybe you don't have access to talk on the port (default 1433). Try and open the port from a using telnet from a command prompt on the web server (XXX is the IP number of the SQL Server):
telnet XXX.XXX.XXX.XXX 1433
If you go to a blank screen then you are connected (you will have to [X] out of the app at that point). Otherwise a connect error will be displayed.
|
|
|
|
|
Cheers but the two are connected and can talk to one another.
|
|
|
|
|
i need help look i disigned a aplication in csharp and i use crystal report
but when i instal the aplicacion run correct when i print some thins they sendme this error
ee the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
CrystalDecisions.CrystalReports.Engine.InternalException: Cannot find KeycodeV2.dll, or invalid keycode.
at .K(String
, EngineExceptionErrorID )
at .G(String , Int32 )
at CrystalDecisions.CrystalReports.Engine.ReportDocument.@()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.InternalInit()
at CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor()
at CrystalDecisions.CrystalReports.Engine.ReportClass..ctor()
at Elias.porfavor..ctor() in C:\Documents and Settings\lobo\Mis documentos\Visual Studio Projects\Elias\porfavor.cs:line 21
at Elias.Form9.button2_Click(Object sender, EventArgs e) in c:\documents and settings\lobo\mis documentos\visual studio projects\elias\form9.cs:line 255
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
I've also been facing this problem , but i found the
solution which worked for me . I donn't whether it's a perfect solution or not someone may present a better to
you. But for now you can try it .
Just uninstall dotNet Framework from the PC on which you are deploying/testing you application , Restart the PC
then again install dotNet framewok perhaps from other source , Your Pervious may not work as i think some of the libraries are missing .
Best of luck
|
|
|
|
|
I use the following code to move to the next record. I need to get the key field data of that record. Can someone please help, I have been reading and searching but I cannot find anything. I do not know how to use the DataRowView code, I think it gets me to the current row. But how do I get the data in a field?
this.BindingContext[dsAnimal1, "animal-info"].Position += 1;
DataRowView rv = (DataRowView)this.BindingContext[dsAnimal1, "animal-info"].Current;
DataRow r = rv.Row;
|
|
|
|
|
I am writing an application where I am using strongly typed DataSets to define the DataTables and relations used in various parts of the application. I have code that takes these DataSets and converts the rows in the DataTables to objects which I then use in my application. The reason for using strongly typed DataSets is so if I change the database schema I only need to validate the DataSets to identify any mismatches at compilation time.
I obviously need to fill the DataSets which is currently done by creating SqlAdapters which call stored procedures to populate the DataTables within the DataSet. This means I have to keep the stored procedures in sync with the DataSets when the schema is changed. I am trying to minimise any potential bugs and so I am looking at ways to ensure the database schema, DataSets and stored procedures are kept in sync.
My current method is to use my own validation tool which performs tests on the DataSets to ensure the stored procedures correctly fill the DataSets.
Given the information contained within the DataSet I was thinking that it should be possible to "auto-generate" the SQL from the DataTables and DataRelations definitions. For a simple situation like Customers and Orders this is not difficult but I was wondering if there are any libraries or tools out there which generate SQL code from a DataSet definition given the complexity that may be involved with many tables and their relationships.
|
|
|
|
|
|
which is the easiest and most efficient means to debug stored procedures?
pls help
|
|
|
|
|
If you are talking about MS SQL Server:
Open SQL Query Analyzer, right click on your stored procedure, click on Debug. It will prompt you to input values for for the parameters, then you click Execute. It will let you single step through the stored proc, and has a window for current variable values.
If debugging is not enabled for your instance of SQL Server, you may have to install the option from cd. Also, it needs the SQL Server Agent service to be running.
To debug triggers, just write a stored proc which will cause a trigger to execute, then you can step into the trigger when debugging the stored proc.
|
|
|
|
|
thanks buddy
cheers
|
|
|
|
|
why do i get this error msg when i try to compile the stored procedure?
[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification
pls help
|
|
|
|
|
Hi,
I am need of a query to retrieve a column by trimming in a particular format.
For example I have a field called UserName. The data is as follows
UserName
--------
user1 (user1@noreply.com)
user2 (user2@noreply.com)
user3 (user3@noreply.com)
Here I want a query to retrieve username data as
user1
user2
user3
I have to trim the content from '(' to ')'
Please Let me know the query.
Thanks in Advance,
Jaya
|
|
|
|
|
select substring(UserName,charindex('(',UserName), charindex(')',UserName)-charindex('(',UserName)) from UserTable
is the sybase syntax. The SQL Server syntax should be equivalent. Please check.
|
|
|
|
|
Hi alam,
Thank you.
I tried your query. Its working fine.
The Query can be written as follows.
select LEFT(UserName,CHARINDEX('(',UserName)-1) FROM UserTable
Regards,
Jaya
|
|
|
|
|
Hi!!!!!!!
SELECT LEFT(USERNAME,PATINDEX('%(%',USERNAME)-1)
Enjoy!!!!
Regards
Shashank
|
|
|
|
|
How to instanciate SQLXMLBulkLoad object in C#?
I have SQL Server 2000 installed and added Microsoft.Data.SqlXml reference to the project, but I can't find any SQLXMLBulkLoad object in it.
What have to be installed to have SQLXMLBulkLoad object?
|
|
|
|
|
Just to follow-up ...
If you are working in .NET C# for example you will need to add the reference to the SQLXML BulkLoad 3.0 Type Library.
(from the below refeences article)
http://www.dbazine.com/sql/sql-articles/cook3
... COM and the .NET Framework are two fundamentally different approaches to application development. COM type libraries must be converted to .NET assembly metadata to achieve COM interop in .NET. By using the Visual Studio .NET IDE, this can be done automatically by following the simple steps that follow. It is assumed that MSXML is already installed.
- Begin by going to the Visual Studio .NET menu bar and selecting Project, then Add Reference.
- From the Add Reference dialog box, select Microsoft SQLXML BulkLoad 3.0 Type Library from the list, click the Select button, and click OK to complete your selection.
- The necessary metadata is automatically generated. The COM object appears as a reference in the solution explorer.
- Use the Object Browser to see what’s available in the component. Go to the menu bar and select View, Other Windows, Object Browser.
- The Object Browser shows you the interfaces and members available.
The rest of the code would be as such ...
SQLXMLBULKLOADLib.SQLXMLBulkLoad3 bulkLoadObj = new SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class();<br />
<br />
<br />
bulkLoadObj.ConnectionString = "Provider=SQLOLEDB;Data Source=localhost;" +<br />
"Integrated Security=SSPI;Initial Catalog=northwind";<br />
<br />
bulkLoadObj.Execute("C:/Locations.xsd", "C:/Locations.xml");
http://www.dbazine.com/sql/sql-articles/cook3
Peace and Love,
Chris Macgowan
|
|
|
|
|
Guys,
I have 3 records defined in the following fields
Company Date Type Amount
COA Sept-205 Cash 500.00
COB Oct-2005 Cash 20.00
COC Oct-2005 Cash 145.00
COD Oct-2005 Cash 0.0
I want to get the average amount per month.
SELECT date, avg(amount)
FROM COTABLE
GROUP BY date.
MY question is IF THE AMOUNT = 0.00 DO NOT INCLUDE IT IN GETTING THE AVERAGE PER MONTH.
In the scenario above, for the month of OCT: the AVERAGE is 55 becuase it's DIVIDED BY 3.
BUT It should be
20.00 + 145.00 = 165.00
165.00 / 2 = 82.5 SINCE the third amount is 0.0 it should not be included in the calculation.
Any help will do. Thanks
|
|
|
|