Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4564022
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:26:32+00:00 2026-05-21T18:26:32+00:00

i want to connect a database to my project but i am getting an

  • 0

i want to connect a database to my project
but i am getting an error on this line

“Data Source=.\SQLEXPRESS;
AttachDbFilename=”c:\users\cj\documents\visual
studio
2010\Projects\WindowsApplication1\WindowsApplication1\cj.mdf”;Integrated
Security=True;User Instance=True”

the error is
Error 1 Character constant must contain exactly one character.
Error 2 Syntax error.

THIS IS THE CODE

Dim ms As New MemoryStream()
Me.PictureBox1.Image.Save(ms, Me.PictureBox1.Image.RawFormat)
Dim arraybuffer() As Byte = ms.GetBuffer
ms.Close()



Dim sqlString As String = "Data Source=.\SQLEXPRESS; AttachDbFilename="c:\\users\\cj\\documents\\visual studio 2010\\Projects\\WindowsApplication1\\WindowsApplication1\\cj.mdf";Integrated Security=True;User Instance=True"
Dim sqlQuery As String = "INSERT INTO image Values(@imagedata)"
Dim sqlcon As New SqlConnection(sqlString)
sqlcon.Open()
Dim sqlcmd As New SqlCommand(sqlQuery, sqlcon)
sqlcmd.Parameters.Add(New SqlParameter("@imagedata", arraybuffer))
MessageBox.Show("IMAGE SAVED IN DATABASE")
sqlcon.Close()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:26:33+00:00Added an answer on May 21, 2026 at 6:26 pm

    You have to escape double quotes (") in string with double double quotes( "" ).

    Try this

    Dim sqlString As String = "Data Source=.\SQLEXPRESS; AttachDbFilename=""c:\users\cj\documents\visual studio 2010\Projects\WindowsApplication1\WindowsApplication1\cj.mdf"";Integrated Security=True;User Instance=True"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to connect database to iphone sdk but it is taking the default
I want to connect to DB2 from excel macro...This is my code, but it
My project has an Entity Framework connection string but I want to connect to
I am done with the project which connects to database (MySQL). Now I want
I want to connect my rails 3 application to firebird database. I have followed
I'm using PDO for connect to the database in a system where I want
I want to develop an application to connect to a PostgreSQL Database, I want
In cakephp I want to be able connect to a different database from one
I want to connect my log4j.xml with log4j.xsd (xml schema). Project don't have any
I have a Java project where I am to connect to a database and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.