|
I think There are several ways of doing this but of which i pretty much sure about is running your sql server instance on a server with Static IP. You also need to configure listener ports on the server.
The connection string will look something like this
This is Oledb provider
Provider=sqloledb;Data Source=10.20.50.100,1521;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd
if you are using Sql client on a Net framework skip the provider part and rest is same.
I hope this is helpful enough
Mandar Patankar
Microsoft Certified professional
|
|
|
|
|
Create hole in the firewall on a different port than standard SQL server and use NAT to move this each side of the firewall. Also filter the IP address range if possible (providing others have fixed IP addresses.)
|
|
|
|
|
I have a small problem with M.Access. I have a form which achieves data from the 'select' query. Beside, this form has the Default View of Continuous Forms and the the scroll-bar property of Vertical only. However, when I run the form, the form always shows the vertical scroll-bar despite of the number of records.
I ever saw another form having the same property with the above form. In contrast, this form only shows the vertical scroll-bar when necessary.
please show me the way to solve this problem. I'm in dark. Thanks a lot.
<vtalau>.
|
|
|
|
|
I am not an ADO expert -- but I have ADO code to fix...
I've got this process which talks to the SQL server a lot. But over time, we start to get errors on the connection. We basically open a single ADO connection and reuse it for all of our stored procedure needs.
My question is this -- is this an appropriate and efficient way to use it. To just open one connection and use it forever.
OR -- is it appropriate to open a connection each time we do a stored procedure?
Also, if the single connection approach is appropriate, how does one fix a messed up connection?
I am just looking for some practical guidelines toward using ADO.
(1) Should I use a single shared connection?
(2) Should I Open() a connection for each stored procedure transaction?
(3) What's the best way to correct a screwed connection?
Thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
I've never experienced this problem.
Normally, the recommended pattern is to create a connection for each operation or small group of related operations. With connection pooling enabled (the default), ADO will keep the physical connection open so it can be reused as required, creating additional connections only as they're needed. Connections that have been idle for a long time will eventually be disconnected.
Most connection objects are not thread-safe, IIRC. If there's a chance you're using your single connection object from multiple threads concurrently, this could well be causing your errors. Switching to a connection-per-operation model should sort this problem out.
In fact the ADO Connection object is marked as Apartment threaded. If you're using the correct operations to pass interface pointers between threads in a multithreaded program, calling a Connection object method will cause COM to marshal the call back to the thread that created the object. If you're not doing it properly, passing raw pointers around, then you could well be corrupting the internal state of the object.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for the clarification. I am no ADO expert, and it seems we have no expert on staff. I changed the code to make a new connection for each operation, and it seems pretty happy.
Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
i'm going to have an 'after update' trigger. but in that trigger i want to know which row has been updated causing this triger. in that triger i want to update another row in other table by id of that updated row.
please help me.
Thanks
Rastegar
|
|
|
|
|
You don't write what DBMS you use !
If you use MS SQL Server you can use in a trigger following tables:
Inserted (inserted ) & Deleted (deleted).
delete table store old values , old records/rows.
inserted table store new values , new records/rows.
For example if you have an trigger for [Order] table:
- deleted table will contain old orders (before update operation) and
- inserted table will contain new order (after update operation).
VB6,C#
|
|
|
|
|
I can't figure out what I'm doing wrong.
I want to list all employees i have by the foreman they are associated with and count the number of installs they have done for the day. I have that part working. However if they have no installs at all for the day then they don't show up at all in the query and i'm wanting a complete employee list.
can someone please help? Here is my current query.
<br />
SELECT Employees_Tony.[Employee Name], MtrInstall.InstallDate, Count(MtrInstall.NewSN) AS CountOfNewSN, MaterialType.UtilityID, Formans_Tony.[Forman Name], Formans_Tony.FormanID, Formans_Tony.FormanID<br />
FROM (MaterialType INNER JOIN MtrAccount ON MaterialType.MaterialTypeID = MtrAccount.MaterialTypeID) INNER JOIN ((Employees_Tony INNER JOIN Formans_Tony ON Employees_Tony.FormanID = Formans_Tony.FormanID) INNER JOIN MtrInstall ON Employees_Tony.[Employee ID] = MtrInstall.EmployeeID) ON MtrAccount.AccountID = MtrInstall.AccountID<br />
GROUP BY Employees_Tony.[Employee Name], MtrInstall.InstallDate, MaterialType.UtilityID, Formans_Tony.[Forman Name], Formans_Tony.FormanID, Formans_Tony.FormanID<br />
HAVING (((MtrInstall.InstallDate)=#8/16/2005#));<br />
Win32newb
"If I wrote a book like I code. It would be one page thick and contain only one word (DUH!)"
|
|
|
|
|
try this
SELECT Employees_Tony.[Employee Name], MtrInstall.InstallDate, Count(MtrInstall.NewSN) AS CountOfNewSN, MaterialType.UtilityID, Formans_Tony.[Forman Name], Formans_Tony.FormanID, Formans_Tony.FormanID
FROM (MaterialType LEFT OUTER JOIN MtrAccount ON MaterialType.MaterialTypeID = MtrAccount.MaterialTypeID) LEFT OUTER JOIN((Employees_Tony LEFT OUTER JOIN Formans_Tony ON Employees_Tony.FormanID = Formans_Tony.FormanID) LEFT OUTER JOIN MtrInstall ON Employees_Tony.[Employee ID] = MtrInstall.EmployeeID) ON MtrAccount.AccountID = MtrInstall.AccountID
GROUP BY Employees_Tony.[Employee Name], MtrInstall.InstallDate, MaterialType.UtilityID, Formans_Tony.[Forman Name], Formans_Tony.FormanID, Formans_Tony.FormanID
HAVING (((MtrInstall.InstallDate)=#8/16/2005#));
|
|
|
|
|
I have an access db used for my webapplication. I'm planning to convert to using MySQL from now on. How is the easiest way to convert my db?
|
|
|
|
|
There are several items listed on the MySQL website that claim to do this. I have tried a few demos and they certainly seem to live up to those claims. Look in the Developers section, under Migration.
|
|
|
|
|
hi, is it possible to use a XML Dokument as a Database? because i dont want to install a SQL Server!
how can i establish a Odbc or Oledb Connection to the XML Database? than i want to fill the DataSet and display it in a DataGrid!
thx in advance! bye
|
|
|
|
|
surfman19 wrote:
is it possible to use a XML Dokument as a Database?
Yes, if it is small and single user you could. However, if it got too large you would incur a large performance penalty. Also, if you need multiple users then you are going to run into all sorts of concurrency problems.
XML is not designed to be used as a database, it is good as a data transfer format though.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
which database (you need oeldb??) do you use if you want to be independent from the operating system?
bye
|
|
|
|
|
|
Yes,
MS walk through using ReadXML.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkWalkthroughAccessingXMLData.asp
|
|
|
|
|
I know sql pretty well but am new to ado.net.
Can anyone suggest a quick reference on SQL commands and syntax that will work with ODBC or OleDb flat-files? Or that will work separately with non-SqlServer datasets in general?
For instance, I'd like to be able to use a t-sql style 'case-when-then' statement but am having no luck using it to pull records from a fixed-width text file I'm connecting to via an ODBC connection (a simple select with a where and order-by clause works fine).
My goal here is to be able to quickly find the syntax for all legal SQL statements within a given context, like any of us would expect with a regular t-sql manual, and know it will apply in a given environment.
I am not finding much help in the vs.net help files or web searches. Maybe I'm not looking in the right place or using the right search expressions? Everything seems to either be rudimentary select statements or assume you are using Sql Server databases.
In case it's helpful: I'm currently working on a console application in vb.net that needs to batch-process data in flat-files we get nightly, massaging the data with conditionals and some string manipulation, and updating other files. It should be possible to handle most of the process with a handful of SQL statements but I'm now looking at writing a bunch of nested vb routines instead. Not happy.
Thanks in advance for any help.
|
|
|
|
|
I have a DataTable with composite key bounded to the DataGrid.
So when the user inserts some data which violates the constraint, an exception is thrown.
What is the right place (event etc) to do any additional custom Validation?
Another problem is the the message that DataTable throws is not user friendly? How can I stop it and give a more meaningful message?
The message I got is
"Error when committing the row to the original data store"
|
|
|
|
|
hi all,
i want to know how to select as item from the dropdownlist in the datagrid
and have the textbox in the datagrid filled with the corresponding value from database.
for eg if i select product name from dropdownlist then the textbox in datagrid must be populated with the price from the database for the corresponding product name.
|
|
|
|
|
override the DataGridTextBoxColumn's Edit function as following and file a custom event
protected override void Edit(System.Windows.Forms.CurrencyManager source, int row, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
{
CustomEventArgs e = null;
this.row = row;
//
//Fire Event and Take Decision
//
if (this.CustomCellEvent != null)
{
e = new CustomEventArgs (row, this.column, isEnabled, bounds);
//Fire the Event in Client Code
this.EnableDisableCellEvent(this, e);
//Take decision based on value of e.IsEnable and e.IsReadOnly set by Client Code
this.isEnabled = e.IsEnable;
this.isReadOnly = e.IsReadOnly;
}
if (this.isEnabled)
{
if (((CurrencyManager) source).Position == row)
{
base.Edit(source, row, bounds, readOnly, instantText, cellIsVisible);
this.source = source;
}
}
}
Subscribe to this event in the User control where the DataGrid is created.
Now in the event handler do the following to display the combobox.
comboBox.Left = this.dataGridAllocation.GetCellBounds(this.currentGridRow, this.currentGridColumn).Left;
comboBox.Top = this.dataGridAllocation.GetCellBounds(this.currentGridRow, this.currentGridColumn).Top;
comboBox.Width = this.dataGridAllocation.GetCellBounds(this.currentGridRow, this.currentGridColumn).Width;
comboBox.Height = this.dataGridAllocation.GetCellBounds(this.currentGridRow, this.currentGridColumn).Height;
comboBox.Visible = true;
comboBox.Focus();
On the SelectedIndexChanged event handler of the combobox
this.dataTable[this.dataGrid.CurrentCell.Row][this.dataGrid.CurrentCell.Column] = this.combobox.Text;
Hope this is useful.
|
|
|
|
|
i'm just learning asp.net, n it's really frustrating as i can't seem to be able to connect to it..
this is a simple code i wrote to insert records into a table called 'Cars" AND A DATABASE Called "MotorSolutions..
here is my code:
<%@ Page Language="vb" debug="true" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
Sub Page_Load(Source As Object, E as EventArgs)
If Page.IsPostBack Then
lblTitle.Text = "Submit was successful"
Else
lblTitle.Text = "Leave the field blank and Submit"
End If
End Sub
Sub btn_click(Src As Object, E As EventArgs)
Dim DBConn as New SqlConnection
Dim DBAdd as New SqlCommand
DBConn = New SqlConnection("server=localhost;database=MotorSolutions;Uid=sa;pwd=5864jc;")
DBAdd.CommandText = "INSERT Into Cars(" _
& "Manufacturer, " _
& "Model) values (" _
& "'" & Replace(txtMF.Text, "'", "''") _
& "', " _
& "'" & Replace(txtModel.Text, "'", "''") _
& "')"
DBAdd.Connection = DBConn
DBAdd.Connection.Open
DBAdd.ExecuteNonQuery()
End Sub
<asp:label id="lblTitle" runat="SERVER">
Manufacturer: | | <asp:textbox id="txtMF" runat="server"> * <asp:requiredfieldvalidator
id="rfvManufacturer"
="" errormessage="Please enter the car manufacturer" runat="server" controltovalidate="txtMF" backcolor="#FFFF80" display="Dynamic"> | | Model : | | <asp:textbox id="txtModel" runat="server">
*
<asp:requiredfieldvalidator
id="rfvModel"
="" errormessage="Please enter the car model" runat="server" controltovalidate="txtModel" backcolor="#FFFF80" display="Dynamic"> | |
<asp:button id="btnSubmit" runat="SERVER" text="Submit" onclick="btn_click">
please can somebody help me...i keep getting this error:
Server Error in '/' Application.
SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
Source Error:
Line 28: & "')"
Line 29: DBAdd.Connection = DBConn
Line 30: DBAdd.Connection.Open
Line 31: DBAdd.ExecuteNonQuery()
Line 32:
Source File: c:\inetpub\wwwroot\motorsolutions\register2.aspx Line: 30
Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.SqlConnection.Open() +761
ASP.register2_aspx.btn_click(Object Src, EventArgs E) in c:\inetpub\wwwroot\motorsolutions\register2.aspx:30
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0
is there something wrong with my connection string...i'd really appreciate it if anyone out there could test my code...my MotorSolutions database consists of only 2 fields:Manufacturer and Model...anyway, if u can't too it's ok..any meaningful feedback will do..Thanking you in advance.
|
|
|
|
|
The error message tells you "SQL Server does not exist or access denied".
This means that there are the following possibilities:
1. The SQL Server is not installed on the machine you refer to. In this case localhost. I've never seen a SQL Server connect to local host so you might want to change that to "(local)" or the name of your machine.
2. The SQL Server is not running. You can use the Microsoft SQL Server Service Manage to ensure that it is running properly.
3. Your log in credentials are wrong. You are using "sa" (a big security risk, if you don't mind me saying) in your web application. If the SQL Server was installed using "Windows Authentication" then the sa account is not accessible (because SQL Server logins are only available in mixed mode authentication). In this case you should use an appropriate trusted connection.
4. The password you supplied is incorrect (and, by the way, thanks for sharing your system administraton password with the world. You do know that with that level of access an attacker can gain control over your machine via SQL Server?).
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
I successfully use 'localhost' as the server in my connection string to SQL Server when I'm using Entrprize Library, but my friend has to change it when he puts my code on his machine. So, sometimes it works, and sometimes it doesn't. I havn't had time to look at why.
|
|
|
|
|
If he puts your code on his machine, localhost won't work to connect to SQL Server on *your* machine, if that's what you mean.
On the other hand, localhost should work at his machine to connect to SQL Server on *his* own machine. I've used localhost with SQL Server before, altough I usually use (local) .
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|