C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Training   ASP.NET Web Hosting    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

Play Silverlight Games or Submit your Silverlight applications and earn 90% AdSense revenue.

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Forums » .NET » .NET »

runtime error in connectio strin


Posted Date: 24 Sep 2008      Posted By: amitkumar      Member Level: Gold     Points: 1   Responses: 3



Hi,
Am using the following code,
Imports System
Imports System.Windows.Forms.Binding
Imports System.Data
Imports System.Text
Imports System.Data.SqlClient
Imports System.IO

Public Class Form1
'Dim flag As Integer
Dim dr As DataRow
Dim dt As DataTable
Dim custid As String
Dim bm As Binding
Dim DSCust As New DataSet

'Dim conn As New OleDbConnection
'Public Sub New()
Dim conn As New SqlConnection("provider=SQLOLEDB;user id=sa;password=ozone1;database=pubs;server=localhost")
'End Sub
Dim OleDbDACust As New SqlDataAdapter("select * from customertraking", conn)
'Public WithEvents datatable As New DSCust

'gstrConnstring = "Provider=SQLOLEDB;Data Source=pubs;user id=sa;password=ozone1;";

'Dim conn As New OleDbConnection(gstrConnstring)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Try
OleDbDACust.Fill(DSCust)
Catch ex As Exception
MsgBox("database connection is not proper", MsgBoxStyle.Critical, "Error")
End Try
'bm = Me.BindingContext(DSCust, "customertraking")

End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' If flag = 1 Then
dt = DSCust.Tables(0)

dr = dt.NewRow()
dr(0) = TextBox1.Text
dr(1) = TextBox2.Text
dr(2) = TextBox3.Text
dr(3) = TextBox4.Text
dr(4) = TextBox5.Text
dr(5) = TextBox6.Text
dt.Rows.Add(dr)
' txtcustid.Enabled = True
OleDbDACust.Update(DSCust, "customertraking")
OleDbDACust.Fill(DSCust)
End Sub
End Class

-
in runtime am getting the following error :
An error occurred creating the form. See Exception.InnerException for details. The error is: Keyword not supported: 'provider'.

please help me to insert a value into sqlbb.

Thanks in advance





Responses

Author: Mithun    24 Sep 2008Member Level: SilverRating:     Points: 1

It might be case sensitive. Provider not provider.


Author: Sathish Kumar    24 Sep 2008Member Level: GoldRating:     Points: 6

Imports System
Imports System.Windows.Forms.Binding
Imports System.Data
Imports System.Text
Imports System.Data.SqlClient
Imports System.IO

Public Class Form1
'Dim flag As Integer
Dim dr As DataRow
Dim dt As DataTable
Dim custid As String
Dim bm As Binding
Dim DSCust As New DataSet

'Dim conn As New OleDbConnection
'Public Sub New()
Dim conn As New SqlConnection("user id=sa;password=ozone1;data source=pubs;server=localhost")
'End Sub
Dim OleDbDACust As New SqlDataAdapter("select * from customertraking", conn)
'Public WithEvents datatable As New DSCust

'gstrConnstring = "Provider=SQLOLEDB;Data Source=pubs;user id=sa;password=ozone1;";

'Dim conn As New OleDbConnection(gstrConnstring)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Try
OleDbDACust.Fill(DSCust)
Catch ex As Exception
MsgBox("database connection is not proper", MsgBoxStyle.Critical, "Error")
End Try
'bm = Me.BindingContext(DSCust, "customertraking")

End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' If flag = 1 Then
dt = DSCust.Tables(0)

dr = dt.NewRow()
dr(0) = TextBox1.Text
dr(1) = TextBox2.Text
dr(2) = TextBox3.Text
dr(3) = TextBox4.Text
dr(4) = TextBox5.Text
dr(5) = TextBox6.Text
dt.Rows.Add(dr)
' txtcustid.Enabled = True
OleDbDACust.Update(DSCust, "customertraking")
OleDbDACust.Fill(DSCust)
End Sub
End Class



Author: Anil Kumar Pandey    24 Sep 2008Member Level: DiamondRating:     Points: 5

hi,

are u using a windows application or a web application for a web application write the string in the web.config file as

<configuration>
<connectionStrings>
<add name="ConStr" connectionString="Data Source=servername;Initial Catalog=dbtable;uid=aa;pwd=aa;Pooling=true;Min Pool Size=0;Max Pool Size=1000;"/>
</connectionStrings>
<system.web>

and read like this

StrConStr = Settings1.Default.SqlConnectionString.ToString();


Regards
Anil Pandey

Thanks & Regards
Anil Kumar Pandey



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : how to draw rectangle,circle using drag and drop method(to draw flow chart) in asp.net(c#)
Previous : ascii
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use