|
Ngobi Arthur wrote: How can i connect SQL database with Vb6.0 application?
By writing code. VB6 is antique, there should be some manuals in the library. If there aren't, there's always the online tutorials[^].
If you are looking for a language to learn, then go for VB.NET.
Bastard Programmer from Hell
|
|
|
|
|
I'm trying to import an Access 2007 db using the SQl Sever Migration Assistant into a SQL Sever 2008 Express database. All the steps work fine in the migration assistant, and in the pane on the lower left I can even see the db in the target server, but when I open the SQL Sever Express db with SQL Sever Management Studio, the db is not there?
I can browse the following folder from windows and I can see the MDF file, but if I try to attach the db, I can browse as far as the DATA folder, but I cant open it to select the actual db.
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\simmstock.mdf
Also if I try to move the mdf file, Windows wont allow it because it is being used by SQL Server???
Solved: I had another instance of SQL server installed on the machine that I was not even aware of (probably from a Visual Studio Installation) and I had migrated the Access database to the wrong server instance
modified 8-Apr-12 10:44am.
|
|
|
|
|
Is there a better way to get one row from a database. I have been using the Fill Method of the DataAdapter to fill a datatable, and then returning the first row of the table
Dim dr As DataRow
Using cn As New OleDb.OleDbConnection(cnStr)
Dim cmd As New OleDb.OleDbCommand(strSelect, cn)
Dim da As New OleDb.OleDbDataAdapter(cmd)
Try
cn.Open()
da.Fill(dt)
If dt.Rows.Count >= 1 Then
dr = dt.Rows(0)
End If
Catch ex As Exception
Finally
cn.Close()
dt = Nothing
End Try
End Using
Return dr
|
|
|
|
|
There sure is. For one thing, if you're using SQL Server you can use SELECT TOP 1 ...
If your database doesn't support that, you can use a DataReader and read only one row (but it won't be a DataRow).
|
|
|
|
|
Thanks PIEBALDconsult
The SELECT query should return only one row based on conditions in the WHERE clause, but I was wondering if there was a way to eliminate declaring a DataTable, and then equating the DataRow to the first row from the DataTable?
|
|
|
|
|
Richard.Berry100 wrote: only one row based on conditions in the WHERE clause
Oh, that's alright then. You probably needn't be too concerned in that case -- if it solves the problem so you can move on and then assess performance and such at a later date.
Other than that, I use a DataReader; I avoid DataAdapters except when I'm very lazy -- and then it always bites me back.
|
|
|
|
|
Richard.Berry100 wrote: but I was wondering if there was a way to eliminate declaring a DataTable, and then equating the DataRow to the first row from the DataTable?
Why? You can simply load the reader in your datatable and return the first row from a method. That way the table is out of scope and discarded.
If you really think that's consuming too much memory, then you should not use a DataRow , but an array of values[^].
Take a look at the section[^] that says "Working with DataReaders".
Bastard Programmer from Hell
|
|
|
|
|
I want to learn step by step implementation of the project tables
If someone can , please send it to me :confused:
|
|
|
|
|
Buy a book, work through some of the 1000s tutorials on the web and learn. Try sqlservercentral.com, they are always a good source of reference material.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
0) Get some data
1) Look for commonalities amongst the data
2) Draw diagrams of the data and the relationships therein
3) Create tables that reflect the relationships in the diagrams
4) Done
|
|
|
|
|
Hi,
I am trying to make Merge Replication for my .NET application and I manged to set it up but I have an issue. I am making the replication every 5 minutes where the publisher and the distributor are on the server and the subscriber on a local machine. Also, I am using pull type subscriber. Inside my .NET application I am accessing the data from my local machine(subscriber), but during the replication process,the data on the subscriber gets deleted which causes a problem to my .NET application and the end user cannot find his/her information because it being deleted and re-inserted into the subscriber later on. This is a serious issue because I am building a POS application and the user need the data instantly.
My questions, is there a way to make the subscriber to do make the pull data without deleting the current data? any idea is very welcome.
Thank you!
|
|
|
|
|
I have no help for you in the replication area, however this does sound like a really bad design. Some questions come to mind
Why do you need the data on a local machine
Why every 5 minutes
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm currently involved in migrating a few SQL apps that currently use DTS to SQL 2008 R2, and I'm looking at the SSIS development workflow.
Is it correct that you can *only* develop SSIS packages on a machine with a full version of SQL Server installed (i.e. not Express)? I've got the VS2008 BIDS installed, but if I try to create an IS project it complains that I don't have Standard, Ent, Dev or Eval versions of SQL installed.
Do people generally install these full SQL Server editions on their dev workstations, then deploy to the dev/test/prod servers?
Or do they use Remote Desktop? (Which seems a really clunky way tbh!)
What about the VS2010 SQL Data Tools? Do they overcome this limitation? (I would try but we're still on XP-SP3.
DTS seemed much easier, Enterprise Manager could develop packadges on whatever server it could connect to, or you could develop local files.
|
|
|
|
|
cjb110 wrote: *only* develop SSIS packages on a machine with a full version of SQL Server
That was my experience when I started using it two months ago.
|
|
|
|
|
The devs on our team doing SSIS do not have the SQL Server database installed, they use SSMS (I'd need to confirm this on Monday).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Just wondering if your devs do have SQL installed?
I can't find any thing suggesting its possible!
|
|
|
|
|
Hi
I am receiving this error recently after i re-installed my windows OS in my project
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Arabic_CI_AS" in the equal to operation.
I should add that this was working before re-instaling the windows and sql server
|
|
|
|
|
You set the default collation of SQL server to a different value than was in your previous installation. Change the default collation for your SQL server to the value which you explicitly set for the column which results in the error shown.
|
|
|
|
|
I posted a question on the same topic, a few days ago. I got some good advice, but now I need to know:
1) Can you explicitly lock a record in Access 2007 - and how?
2) Can you explicitly lock a table in Access 2007 - and how?
3) From a vb.net app using ACE to connect - how can I tell if a record or table is locked?
|
|
|
|
|
Richard.Berry100 wrote: I posted a question on the same topic, a few days ago
I'm too lazy to search the forum for that particular post. A link would have been nice
Access isn't meant as a multi-user database-server. You can upgrade to Sql Express (which is free) using the "upsize wizard" that's embedded in Access.
Bastard Programmer from Hell
|
|
|
|
|
Thanks for your reply Eddy.
1) The link to the previous question was http://www.codeproject.com/Messages/4207612/How-do-you-lock-records-in-Access-2007.aspx[^][]
2) I am planning on moving to SSE but I need a quick fix for Access now. (I used a lot of parameterized queries, and Access allows '?'as a parameter name, while SQL server wants actual field names '@@name' and I have to update all the queries before I can move to SSE
3) I have searched Google, and cant find how to lock records, but I did find a post on another forum where it seems you do it in the connection string - but I cant find the syntax to use. I would alos assume the locking in OleDb (for Access) will be similar in SqlDb (For SSE)
|
|
|
|
|
|
Thanks JOAT-MON
That did help! (I think...)
Provider=Microsoft.ACE.OLEDB.12.0;Data source= C:\myDb.accdb; Jet OLEDB:Database Locking Mode=1
'Locking mode: 0 = Page Level, 1 = Record Level
Do you have any idea how I can test this on my pc at home to see if the record is locked?
My code to update the stock quantity is as follows, so I thought of running one instance of the app from Visual Studio and setting a breakpoint somewhere in the code, and then running a second instance of the app on its own from the exe and trying to update the same record, but not sure where I can set the breakpoint.
Friend Function AddStkReceived(ByVal TransactType As String, ByVal StockCode As String, ByVal WH As String, ByVal Qty As Double, ByVal Comment As String) As Boolean
Dim sucess As Boolean = False
If IsNothing(Comment) Then Comment = ""
Dim params() As String = {Qty, StockCode, WH}
Dim strUpdate As String = "UPDATE stock_qty SET Qty = Qty + ? WHERE StockCode = ? AND WH = ?"
If Not DA.UpdateRecord2(strUpdate, params) Then
sucess = False
Else
sucess = True
End If
If sucess Then
If Not WriteStkHist(StockCode, Qty, TransactType, WH, Comment) Then
sucess = False
Else
sucess = True
End If
End If
Return sucess
End Function
Public Function UpdateRecord2(ByVal strUpdate As String, params() As String) As Boolean
Dim RecordsUpdated As Integer = 0
Dim result As Boolean = False
Using cn As New OleDb.OleDbConnection(cnStr)
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
Dim cmd As OleDb.OleDbCommand
cmd = New OleDb.OleDbCommand(strUpdate, cn)
cmd.CommandTimeout = 30
For i As Integer = 0 To params.Length - 1
If params(i) = Nothing Then params(i) = ""
cmd.Parameters.AddWithValue("?", params(i))
Next
da.InsertCommand = cmd
Try
cn.Open()
RecordsUpdated = da.InsertCommand.ExecuteNonQuery()
cn.Close()
If RecordsUpdated = 1 Then
result = True
Else
result = False
End If
Catch ex As Exception
result = False
Finally
cn.Close()
End Try
End Using
Return result
End Function
modified 6-Apr-12 4:22am.
|
|
|
|
|
I haven't done any tests on record locking, so I may not be the best person to ask. but as I understand it, there are two type of locking (optimistic and pessimistic). Pessimistic only allows one user to use it at a time and will hold the lock. Optimistic, however, only locks the record at the moment it is updating then releases it. I am not sure what type of locking is implemented by the command line instruction above, but if it is optimistic it may not be possible to test it reliably.
Sorry I can't be more helpful on that.
Jack of all trades ~ Master of none.
|
|
|
|
|
1) Thanks - keeps me from posting answers that you already seen
2) It doesn't have to be the name of the field, but the names do have to match in the parameters. Using "@1" in the query and adding a parameter called "@1" will put that value on that position.
3) Access is a flat-file database, ideal for a single user. Sql Server is a database-server product, ideal for multiple users. It doesn't lock records, but pages.
Never had much concurrency-problems in Sql Server. Had a lot of them in Access.
Bastard Programmer from Hell
|
|
|
|